bugfix + changes

- added getMinScroll and getMaxScroll for frames
- fixed a small bug with dynamicvalues
- textfield got a :clear() function
- improved the focus system
- fixed a bug with dynamic values getting into a infinite loop
This commit is contained in:
Robert Jelic
2022-07-25 21:09:37 +02:00
parent 738ad2576e
commit f2e2e773f5
8 changed files with 154 additions and 100 deletions

View File

@@ -45,6 +45,7 @@ return function(name)
local animations = {}
local animationTime = 0
local animationActive = false
local index = 1
local infinitePlay = false
@@ -279,7 +280,7 @@ return function(name)
offset = function(self, x, y, duration, timer, obj)
_OBJ = obj or _OBJ
predefinedLerp(x,y,duration,timer or 0,_OBJ.getOffsetInternal,_OBJ.setOffset)
predefinedLerp(x,y,duration,timer or 0,_OBJ.getOffset,_OBJ.setOffset)
return self
end,
@@ -384,6 +385,7 @@ return function(name)
play = function(self, infinite)
self:cancel()
animationActive = true
infinitePlay = infinite and true or false
index = 1
animationTime = 0
@@ -404,6 +406,7 @@ return function(name)
os.cancelTimer(timerObj)
infinitePlay = false
end
animationActive = false
return self
end;
@@ -412,11 +415,13 @@ return function(name)
end,
eventHandler = function(self, event, tObj)
if (event == "timer") and (tObj == timerObj) then
if (animations[index] ~= nil) then
onPlay(self)
else
self:animationDoneHandler()
if(animationActive)then
if (event == "timer") and (tObj == timerObj) then
if (animations[index] ~= nil) then
onPlay(self)
else
self:animationDoneHandler()
end
end
end
end;

View File

@@ -1,6 +1,7 @@
local Object = require("Object")
local utils = require("utils")
local xmlValue = utils.getValueFromXML
local createText = utils.createText
local tHex = require("tHex")
local bigFont = require("bigfont")
@@ -95,17 +96,7 @@ return function(name)
if(self.fgColor~=false)then self.parent:drawForegroundBox(obx, oby, w, h, self.fgColor) end
if(fontsize==0)then
if not(autoSize)then
local splittedText = utils.splitString(self:getValue(), " ")
local text = {}
local line = ""
for _,v in pairs(splittedText)do
if(line:len()+v:len()<=w)then
line = line=="" and v or line.." "..v
else
table.insert(text, line)
line = v:sub(1,w)
end
end
local text = createText(self:getValue(), self:getWidth())
for k,v in pairs(text)do
self.parent:setText(obx, oby+k-1, v)
end

View File

@@ -104,12 +104,17 @@ return function(name)
return self
end;
setActiveSymbol = function(self, sym)
symbol = sym:sub(1,1)
return self
end,
setSelectedItem = function(self, bgCol, fgCol, boxBG, boxFG, active)
itemSelectedBG = bgCol or itemSelectedBG
itemSelectedFG = fgCol or itemSelectedFG
boxSelectedBG = boxBG or boxSelectedBG
boxSelectedFG = boxFG or boxSelectedFG
selectionColorActive = active
selectionColorActive = active~=nil and active or true
return self
end;
@@ -123,7 +128,7 @@ return function(name)
if (self.parent ~= nil) then
self.parent:setFocusedObject(self)
end
--eventSystem:sendEvent(event, self, event, button, x, y)
self:getEventSystem():sendEvent(event, self, event, button, x, y)
self:setVisualChanged()
return true
end

View File

@@ -147,6 +147,14 @@ return function(name)
return self
end;
clear = function(self)
lines = {""}
bgLines = {""}
fgLines = {""}
hIndex, wIndex, textX, textY = 1, 1, 1, 1
return self
end,
addLine = function(self, text, index)
if(text~=nil)then
if(#lines==1)and(lines[1]=="")then