Small Changes
- Fixed a bug in basalt.setMouseDragThrottle
- Added some new curves for animation (anim:setMode("curveyouwant")
- Small fix for checkbox -> mouse_up
- Fix for Input (if type is number and you use . or - it gets ignored)
This commit is contained in:
@@ -190,18 +190,20 @@ local function moveHandlerTimer()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local btn, dragX, dragY = nil, nil, nil
|
local btn, dragX, dragY = nil, nil, nil
|
||||||
|
local dragTimer = nil
|
||||||
local function dragHandlerTimer()
|
local function dragHandlerTimer()
|
||||||
|
log("Event registered")
|
||||||
dragTimer = nil
|
dragTimer = nil
|
||||||
mainFrame:dragHandler(btn, dragX, dragY)
|
mainFrame:dragHandler(btn, dragX, dragY)
|
||||||
activeFrame = mainFrame
|
activeFrame = mainFrame
|
||||||
end
|
end
|
||||||
|
|
||||||
local dragTimer = nil
|
|
||||||
local function mouseDragEvent(b, x, y)
|
local function mouseDragEvent(b, x, y)
|
||||||
btn, dragX, dragY = b, x, y
|
btn, dragX, dragY = b, x, y
|
||||||
if(dragThrottle<50)then
|
if(dragThrottle<50)then
|
||||||
dragHandlerTimer()
|
dragHandlerTimer()
|
||||||
else
|
else
|
||||||
|
log("Draggi"..(tostring(dragTimer)..(dragThrottle/1000)))
|
||||||
if(dragTimer==nil)then
|
if(dragTimer==nil)then
|
||||||
dragTimer = os.startTimer(dragThrottle/1000)
|
dragTimer = os.startTimer(dragThrottle/1000)
|
||||||
end
|
end
|
||||||
@@ -215,8 +217,6 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
|||||||
mainFrame:mouseHandler(p1, p2, p3, false)
|
mainFrame:mouseHandler(p1, p2, p3, false)
|
||||||
activeFrame = mainFrame
|
activeFrame = mainFrame
|
||||||
elseif (event == "mouse_drag") then
|
elseif (event == "mouse_drag") then
|
||||||
--mainFrame:dragHandler(p1, p2, p3, p4)
|
|
||||||
--activeFrame = mainFrame
|
|
||||||
mouseDragEvent(p1, p2, p3)
|
mouseDragEvent(p1, p2, p3)
|
||||||
elseif (event == "mouse_up") then
|
elseif (event == "mouse_up") then
|
||||||
mainFrame:mouseUpHandler(p1, p2, p3, p4)
|
mainFrame:mouseUpHandler(p1, p2, p3, p4)
|
||||||
@@ -315,9 +315,11 @@ basalt = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
setMouseDragThrottle = function(amount)
|
setMouseDragThrottle = function(amount)
|
||||||
if(amount<0)then
|
log("Drag Throttle "..amount)
|
||||||
|
if(amount<=0)then
|
||||||
dragThrottle = 0
|
dragThrottle = 0
|
||||||
else
|
else
|
||||||
|
dragTimer = nil
|
||||||
dragThrottle = amount
|
dragThrottle = amount
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
local xmlValue = require("utils").getValueFromXML
|
local xmlValue = require("utils").getValueFromXML
|
||||||
local basaltEvent = require("basaltEvent")
|
local basaltEvent = require("basaltEvent")
|
||||||
|
|
||||||
local floor,sin,cos,pi = math.floor,math.sin,math.cos,math.pi
|
local floor,sin,cos,pi,sqrt,pow = math.floor,math.sin,math.cos,math.pi,math.sqrt,math.pow
|
||||||
|
|
||||||
|
-- You can find the easing curves here https://easings.net
|
||||||
|
|
||||||
local lerp = function(s, e, pct)
|
local lerp = function(s, e, pct)
|
||||||
return s + (e - s) * pct
|
return s + (e - s) * pct
|
||||||
@@ -39,16 +41,183 @@ local easeInOutSine = function(t)
|
|||||||
return -(cos(pi * x) - 1) / 2
|
return -(cos(pi * x) - 1) / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local easeInBack = function(t)
|
||||||
|
local c1 = 1.70158;
|
||||||
|
local c3 = c1 + 1
|
||||||
|
return c3*t^3-c1*t^2
|
||||||
|
end
|
||||||
|
|
||||||
|
local easeInCubic = function(t)
|
||||||
|
return t^3
|
||||||
|
end
|
||||||
|
|
||||||
|
local easeInElastic = function(t)
|
||||||
|
local c4 = (2*pi)/3;
|
||||||
|
return t == 0 and 0 or (t == 1 and 1 or (
|
||||||
|
-2^(10*t-10)*sin((t*10-10.75)*c4)
|
||||||
|
))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInExpo(t)
|
||||||
|
return t == 0 and 0 or 2^(10*t-10)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInExpo(t)
|
||||||
|
return t == 0 and 0 or 2^(10*t-10)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInOutBack(t)
|
||||||
|
local c1 = 1.70158;
|
||||||
|
local c2 = c1 * 1.525;
|
||||||
|
return t < 0.5 and ((2*t)^2*((c2+1)*2*t-c2))/2 or ((2*t-2)^2*((c2+1)*(t*2-2)+c2)+2)/2
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInOutCubic(t)
|
||||||
|
return t < 0.5 and 4 * t^3 or 1-(-2*t+2)^3 / 2
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInOutElastic(t)
|
||||||
|
local c5 = (2*pi) / 4.5
|
||||||
|
return t==0 and 0 or (t == 1 and 1 or (t < 0.5 and -(2^(20*t-10) * sin((20*t - 11.125) * c5))/2 or (2^(-20*t+10) * sin((20*t - 11.125) * c5))/2 + 1))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInOutExpo(t)
|
||||||
|
return t == 0 and 0 or (t == 1 and 1 or (t < 0.5 and 2^(20*t-10)/2 or (2-2^(-20*t+10)) /2))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInOutQuad(t)
|
||||||
|
return t < 0.5 and 2*t^2 or 1-(-2*t+2)^2/2
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInOutQuart(t)
|
||||||
|
return t < 0.5 and 8*t^4 or 1 - (-2*t+2)^4 / 2
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInOutQuint(t)
|
||||||
|
return t < 0.5 and 16*t^5 or 1-(-2*t+2)^5 / 2
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInQuad(t)
|
||||||
|
return t^2
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInQuart(t)
|
||||||
|
return t^4
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInQuint(t)
|
||||||
|
return t^5
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeOutBack(t)
|
||||||
|
local c1 = 1.70158;
|
||||||
|
local c3 = c1 + 1
|
||||||
|
return 1+c3*(t-1)^3+c1*(t-1)^2
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeOutCubic(t)
|
||||||
|
return 1 - (1-t)^3
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeOutElastic(t)
|
||||||
|
local c4 = (2*pi)/3;
|
||||||
|
|
||||||
|
return t == 0 and 0 or (t == 1 and 1 or (2^(-10*t)*sin((t*10-0.75)*c4)+1))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeOutExpo(t)
|
||||||
|
return t == 1 and 1 or 1-2^(-10*t)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeOutQuad(t)
|
||||||
|
return 1 - (1 - t) * (1 - t)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeOutQuart(t)
|
||||||
|
return 1 - (1-t)^4
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeOutQuint(t)
|
||||||
|
return 1 - (1 - t)^5
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInCirc(t)
|
||||||
|
return 1 - sqrt(1 - pow(t, 2))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeOutCirc(t)
|
||||||
|
return sqrt(1 - pow(t - 1, 2))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInOutCirc(t)
|
||||||
|
return t < 0.5 and (1 - sqrt(1 - pow(2 * t, 2))) / 2 or (sqrt(1 - pow(-2 * t + 2, 2)) + 1) / 2;
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeOutBounce(t)
|
||||||
|
local n1 = 7.5625;
|
||||||
|
local d1 = 2.75;
|
||||||
|
|
||||||
|
if (t < 1 / d1)then
|
||||||
|
return n1 * t * t
|
||||||
|
elseif (t < 2 / d1)then
|
||||||
|
local a = t - 1.5 / d1
|
||||||
|
return n1 * a * a + 0.75;
|
||||||
|
elseif (t < 2.5 / d1)then
|
||||||
|
local a = t - 2.25 / d1
|
||||||
|
return n1 * a * a + 0.9375;
|
||||||
|
else
|
||||||
|
local a = t - 2.625 / d1
|
||||||
|
return n1 * a * a + 0.984375;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInBounce(t)
|
||||||
|
return 1 - easeOutBounce(1 - t)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function easeInOutBounce(t)
|
||||||
|
return x < 0.5 and (1 - easeOutBounce(1 - 2 * t)) / 2 or (1 + easeOutBounce(2 * t - 1)) / 2;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local lerp = {
|
local lerp = {
|
||||||
linear = linear,
|
linear = linear,
|
||||||
lerp = lerp,
|
lerp = lerp,
|
||||||
flip=flip,
|
flip=flip,
|
||||||
easeIn=easeIn,
|
easeIn=easeIn,
|
||||||
easeOut=easeOut,
|
|
||||||
easeInOut=easeInOut,
|
|
||||||
easeOutSine = easeOutSine,
|
|
||||||
easeInSine = easeInSine,
|
easeInSine = easeInSine,
|
||||||
|
easeInBack=easeInBack,
|
||||||
|
easeInCubic=easeInCubic,
|
||||||
|
easeInElastic=easeInElastic,
|
||||||
|
easeInExpo=easeInExpo,
|
||||||
|
easeInQuad=easeInQuad,
|
||||||
|
easeInQuart=easeInQuart,
|
||||||
|
easeInQuint=easeInQuint,
|
||||||
|
easeInCirc=easeInCirc,
|
||||||
|
easeInBounce=easeInBounce,
|
||||||
|
easeOut=easeOut,
|
||||||
|
easeOutSine = easeOutSine,
|
||||||
|
easeOutBack=easeOutBack,
|
||||||
|
easeOutCubic=easeOutCubic,
|
||||||
|
easeOutElastic=easeOutElastic,
|
||||||
|
easeOutExpo=easeOutExpo,
|
||||||
|
easeOutQuad=easeOutQuad,
|
||||||
|
easeOutQuart=easeOutQuart,
|
||||||
|
easeOutQuint=easeOutQuint,
|
||||||
|
easeOutCirc=easeOutCirc,
|
||||||
|
easeOutBounce=easeOutBounce,
|
||||||
|
easeInOut=easeInOut,
|
||||||
easeInOutSine = easeInOutSine,
|
easeInOutSine = easeInOutSine,
|
||||||
|
easeInOutBack=easeInOutBack,
|
||||||
|
easeInOutCubic=easeInOutCubic,
|
||||||
|
easeInOutElastic=easeInOutElastic,
|
||||||
|
easeInOutExpo=easeInOutExpo,
|
||||||
|
easeInOutQuad=easeInOutQuad,
|
||||||
|
easeInOutQuart=easeInOutQuart,
|
||||||
|
easeInOutQuint=easeInOutQuint,
|
||||||
|
easeInOutCirc=easeInOutCirc,
|
||||||
|
easeInOutBounce=easeInOutBounce,
|
||||||
}
|
}
|
||||||
|
|
||||||
local activeAnimations = {}
|
local activeAnimations = {}
|
||||||
@@ -185,6 +354,11 @@ return function(name)
|
|||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
addMode = function(self, modeId, modeF)
|
||||||
|
lerp[modeId] = modeF
|
||||||
|
return self
|
||||||
|
end,
|
||||||
|
|
||||||
generateXMLEventFunction = function(self, func, val)
|
generateXMLEventFunction = function(self, func, val)
|
||||||
local createF = function(str)
|
local createF = function(str)
|
||||||
if(str:sub(1,1)=="#")then
|
if(str:sub(1,1)=="#")then
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ return function(name)
|
|||||||
self.bgColor = self.parent:getTheme("CheckboxBG")
|
self.bgColor = self.parent:getTheme("CheckboxBG")
|
||||||
self.fgColor = self.parent:getTheme("CheckboxText")
|
self.fgColor = self.parent:getTheme("CheckboxText")
|
||||||
self.parent:addEvent("mouse_click", self)
|
self.parent:addEvent("mouse_click", self)
|
||||||
|
self.parent:addEvent("mouse_up", self)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,12 +202,12 @@ return function(name)
|
|||||||
if (text:len() < inputLimit or inputLimit <= 0) then
|
if (text:len() < inputLimit or inputLimit <= 0) then
|
||||||
if (inputType == "number") then
|
if (inputType == "number") then
|
||||||
local cache = text
|
local cache = text
|
||||||
if (char == ".") or (tonumber(char) ~= nil) then
|
if (#text==0 and char == "-") or (char == ".") or (tonumber(char) ~= nil) then
|
||||||
self:setValue(text:sub(1, textX - 1) .. char .. text:sub(textX, text:len()))
|
self:setValue(text:sub(1, textX - 1) .. char .. text:sub(textX, text:len()))
|
||||||
textX = textX + 1
|
textX = textX + 1
|
||||||
end
|
end
|
||||||
if (tonumber(base.getValue()) == nil) then
|
if (tonumber(base.getValue()) == nil) then
|
||||||
self:setValue(cache)
|
--self:setValue(cache)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:setValue(text:sub(1, textX - 1) .. char .. text:sub(textX, text:len()))
|
self:setValue(text:sub(1, textX - 1) .. char .. text:sub(textX, text:len()))
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ return function(name)
|
|||||||
text = tostring(text)
|
text = tostring(text)
|
||||||
base:setValue(text)
|
base:setValue(text)
|
||||||
if (autoSize) then
|
if (autoSize) then
|
||||||
self.width = text:len()
|
base.width = text:len()
|
||||||
end
|
end
|
||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
|
|||||||
Reference in New Issue
Block a user