couple of bugfixes
-fixed screen flickering -fixed menubar (now works as intended) -reworked sliders (behaviour more like scrollbars) -visual fix to dropdowns
This commit is contained in:
@@ -648,10 +648,6 @@ local function Object(name)
|
|||||||
return isVisible
|
return isVisible
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getZIndex = function(self)
|
|
||||||
return zIndex;
|
|
||||||
end;
|
|
||||||
|
|
||||||
setFocus = function(self)
|
setFocus = function(self)
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setFocusedObject(self)
|
self.parent:setFocusedObject(self)
|
||||||
@@ -668,6 +664,10 @@ local function Object(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getZIndex = function(self)
|
||||||
|
return zIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
getType = function(self)
|
getType = function(self)
|
||||||
return objectType
|
return objectType
|
||||||
end;
|
end;
|
||||||
@@ -713,6 +713,7 @@ local function Object(name)
|
|||||||
|
|
||||||
setVisualChanged = function(self, change)
|
setVisualChanged = function(self, change)
|
||||||
visualsChanged = change or true
|
visualsChanged = change or true
|
||||||
|
if(change == nil)then visualsChanged = true end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -1121,6 +1122,7 @@ local function Button(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -1177,6 +1179,7 @@ local function Checkbox(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -1204,7 +1207,7 @@ local function Dropdown(name)
|
|||||||
local dropdownH = 6
|
local dropdownH = 6
|
||||||
local closedSymbol = "\16"
|
local closedSymbol = "\16"
|
||||||
local openedSymbol = "\31"
|
local openedSymbol = "\31"
|
||||||
local state = 1
|
local isOpened = false
|
||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
getType = function(self)
|
getType = function(self)
|
||||||
@@ -1281,7 +1284,7 @@ local function Dropdown(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (state == 2) then
|
if (isOpened) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
||||||
|
|
||||||
@@ -1316,9 +1319,9 @@ local function Dropdown(name)
|
|||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(self, event, button, x, y)) then
|
||||||
state = 2
|
isOpened = true
|
||||||
else
|
else
|
||||||
state = 1
|
isOpened = false
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -1327,20 +1330,14 @@ local function Dropdown(name)
|
|||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
if (#list >= 1) then
|
local val = self:getValue()
|
||||||
if (self:getValue() ~= nil) then
|
local text = getTextHorizontalAlign((val~=nil and val.text or ""), self.width, align):sub(1, self.width - 1) .. (isOpened and openedSymbol or closedSymbol)
|
||||||
if (self:getValue().text ~= nil) then
|
self.parent:writeText(obx, oby, text, self.bgColor, self.fgColor)
|
||||||
if (state == 1) then
|
|
||||||
self.parent:writeText(obx, oby, getTextHorizontalAlign(self:getValue().text, self.width, align):sub(1, self.width - 1) .. closedSymbol, self.bgColor, self.fgColor)
|
if (isOpened) then
|
||||||
else
|
|
||||||
self.parent:writeText(obx, oby, getTextHorizontalAlign(self:getValue().text, self.width, align):sub(1, self.width - 1) .. openedSymbol, self.bgColor, self.fgColor)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (state == 2) then
|
|
||||||
for n = 1, dropdownH do
|
for n = 1, dropdownH do
|
||||||
if (list[n + yOffset] ~= nil) then
|
if (list[n + yOffset] ~= nil) then
|
||||||
if (list[n + yOffset] == self:getValue()) then
|
if (list[n + yOffset] == val) then
|
||||||
if (selectionColorActive) then
|
if (selectionColorActive) then
|
||||||
self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), itemSelectedBG, itemSelectedFG)
|
self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), itemSelectedBG, itemSelectedFG)
|
||||||
else
|
else
|
||||||
@@ -1353,7 +1350,7 @@ local function Dropdown(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -1546,6 +1543,7 @@ local function Image(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -1787,6 +1785,7 @@ local function Input(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -1883,6 +1882,7 @@ local function Label(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -2042,6 +2042,7 @@ local function List(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -2065,16 +2066,20 @@ local function Menubar(name)
|
|||||||
local selectionColorActive = true
|
local selectionColorActive = true
|
||||||
local align = "left"
|
local align = "left"
|
||||||
local itemOffset = 0
|
local itemOffset = 0
|
||||||
local space = 2
|
local space = 1
|
||||||
local scrollable = false
|
local scrollable = false
|
||||||
|
|
||||||
local function maxScroll()
|
local function maxScroll()
|
||||||
local mScroll = 0
|
local mScroll = 0
|
||||||
local xPos = 1
|
local xPos = 0
|
||||||
for n = 1, #list do
|
for n = 1, #list do
|
||||||
if (xPos + list[n].text:len() + space * 2 > object.w) then
|
if (xPos + list[n].text:len() + space * 2 > object.width) then
|
||||||
|
if(xPos < object.width)then
|
||||||
|
mScroll = mScroll + (list[n].text:len() + space * 2-(object.width - xPos))
|
||||||
|
else
|
||||||
mScroll = mScroll + list[n].text:len() + space * 2
|
mScroll = mScroll + list[n].text:len() + space * 2
|
||||||
end
|
end
|
||||||
|
end
|
||||||
xPos = xPos + list[n].text:len() + space * 2
|
xPos = xPos + list[n].text:len() + space * 2
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -2118,7 +2123,7 @@ local function Menubar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setButtonOffset = function(self, offset)
|
setPositionOffset = function(self, offset)
|
||||||
itemOffset = offset or 0
|
itemOffset = offset or 0
|
||||||
if (itemOffset < 0) then
|
if (itemOffset < 0) then
|
||||||
itemOffset = 0
|
itemOffset = 0
|
||||||
@@ -2131,8 +2136,13 @@ local function Menubar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getPositionOffset = function(self)
|
||||||
|
return itemOffset
|
||||||
|
end;
|
||||||
|
|
||||||
setScrollable = function(self, scroll)
|
setScrollable = function(self, scroll)
|
||||||
scrollable = scroll
|
scrollable = scroll
|
||||||
|
if(scroll==nil)then scrollable = true end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -2168,24 +2178,22 @@ local function Menubar(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
|
if(base.mouseClickHandler(self, event, button, x, y))then
|
||||||
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then
|
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setFocusedObject(self)
|
self.parent:setFocusedObject(self)
|
||||||
end
|
end
|
||||||
if (event == "mouse_click") or (event == "monitor_touch") then
|
if (event == "mouse_click") or (event == "monitor_touch") then
|
||||||
local xPos = 1
|
local xPos = 0
|
||||||
for n = 1 + itemOffset, #list do
|
for n = 1, #list do
|
||||||
if (list[n] ~= nil) then
|
if (list[n] ~= nil) then
|
||||||
if (xPos + list[n].text:len() + space * 2 <= self.width) then
|
--if (xPos-1 + list[n].text:len() + space * 2 <= self.width) then
|
||||||
if (objX + (xPos - 1) <= x) and (objX + (xPos - 1) + list[n].text:len() + space * 2 > x) and (objY == y) then
|
if (objX + xPos <= x + itemOffset) and (objX + xPos + list[n].text:len() + (space*2) > x + itemOffset) and (objY == y) then
|
||||||
self:setValue(list[n])
|
self:setValue(list[n])
|
||||||
self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n])
|
self:getEventSystem():sendEvent(event, self, event, 0, x, y, list[n])
|
||||||
end
|
end
|
||||||
xPos = xPos + list[n].text:len() + space * 2
|
xPos = xPos + list[n].text:len() + space * 2
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2202,8 +2210,10 @@ local function Menubar(name)
|
|||||||
itemOffset = mScroll
|
itemOffset = mScroll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(true)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -2212,27 +2222,26 @@ local function Menubar(name)
|
|||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
local xPos = 0
|
local text = ""
|
||||||
for _, value in pairs(list) do
|
local textBGCol = ""
|
||||||
if (xPos + value.text:len() + space * 2 <= self.width) then
|
local textFGCol = ""
|
||||||
if (value == self:getValue()) then
|
for _, v in pairs(list) do
|
||||||
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align), itemSelectedBG or value.bgCol, itemSelectedFG or value.fgCol)
|
local newItem = (" "):rep(space) .. v.text .. (" "):rep(space)
|
||||||
|
text = text .. newItem
|
||||||
|
if(v == self:getValue())then
|
||||||
|
textBGCol = textBGCol .. tHex[itemSelectedBG or v.bgCol or self.bgColor]:rep(newItem:len())
|
||||||
|
textFGCol = textFGCol .. tHex[itemSelectedFG or v.FgCol or self.fgColor]:rep(newItem:len())
|
||||||
else
|
else
|
||||||
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align), value.bgCol, value.fgCol)
|
textBGCol = textBGCol .. tHex[v.bgCol or self.bgColor]:rep(newItem:len())
|
||||||
end
|
textFGCol = textFGCol .. tHex[v.FgCol or self.fgColor]:rep(newItem:len())
|
||||||
xPos = xPos + value.text:len() + space * 2
|
|
||||||
else
|
|
||||||
if (xPos < self.width + itemOffset) then
|
|
||||||
if (value == self:getValue()) then
|
|
||||||
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align):sub(1, self.width + itemOffset - xPos), itemSelectedBG or value.bgCol, itemSelectedFG or value.fgCol)
|
|
||||||
else
|
|
||||||
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align):sub(1, self.width + itemOffset - xPos), value.bgCol, value.fgCol)
|
|
||||||
end
|
|
||||||
xPos = xPos + value.text:len() + space * 2
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.parent:setText(obx, oby, text:sub(itemOffset+1, self.width+itemOffset))
|
||||||
|
self.parent:setBG(obx, oby, textBGCol:sub(itemOffset+1, self.width+itemOffset))
|
||||||
|
self.parent:setFG(obx, oby, textFGCol:sub(itemOffset+1, self.width+itemOffset))
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -2256,6 +2265,7 @@ local function Pane(name)
|
|||||||
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
self.parent:drawForegroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawForegroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -2898,6 +2908,7 @@ local function Program(name)
|
|||||||
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
pWindow.basalt_update()
|
pWindow.basalt_update()
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -2997,6 +3008,7 @@ local function Progressbar(name)
|
|||||||
self.parent:drawTextBox(obx, oby, self.width / 100 * progress, self.height, activeBarSymbol)
|
self.parent:drawTextBox(obx, oby, self.width / 100 * progress, self.height, activeBarSymbol)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -3122,6 +3134,7 @@ local function Radio(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -3251,6 +3264,7 @@ local function Scrollbar(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -3262,6 +3276,7 @@ local function Slider(name)
|
|||||||
local objectType = "Slider"
|
local objectType = "Slider"
|
||||||
|
|
||||||
base.width = 8
|
base.width = 8
|
||||||
|
base.height = 1
|
||||||
base.bgColor = colors.lightGray
|
base.bgColor = colors.lightGray
|
||||||
base.fgColor = colors.gray
|
base.fgColor = colors.gray
|
||||||
base:setValue(1)
|
base:setValue(1)
|
||||||
@@ -3272,6 +3287,7 @@ local function Slider(name)
|
|||||||
local bgSymbol = "\140"
|
local bgSymbol = "\140"
|
||||||
local maxValue = base.width
|
local maxValue = base.width
|
||||||
local index = 1
|
local index = 1
|
||||||
|
local symbolSize = 1
|
||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
getType = function(self)
|
getType = function(self)
|
||||||
@@ -3284,6 +3300,22 @@ local function Slider(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
setSymbolSize = function(self, size)
|
||||||
|
symbolSize = tonumber(size) or 1
|
||||||
|
if (barType == "vertical") then
|
||||||
|
self:setValue(index - 1 * (maxValue / (self.height - (symbolSize - 1))) - (maxValue / (self.height - (symbolSize - 1))))
|
||||||
|
elseif (barType == "horizontal") then
|
||||||
|
self:setValue(index - 1 * (maxValue / (self.width - (symbolSize - 1))) - (maxValue / (self.width - (symbolSize - 1))))
|
||||||
|
end
|
||||||
|
self:setVisualChanged()
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
setMaxValue = function(self, val)
|
||||||
|
maxValue = val
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
setBackgroundSymbol = function(self, _bgSymbol)
|
setBackgroundSymbol = function(self, _bgSymbol)
|
||||||
bgSymbol = string.sub(_bgSymbol, 1, 1)
|
bgSymbol = string.sub(_bgSymbol, 1, 1)
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
@@ -3301,63 +3333,38 @@ local function Slider(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setValue = function(self, val)
|
|
||||||
index = math.floor(val / maxValue)
|
|
||||||
if (barType == "horizontal") then
|
|
||||||
if(index<1)then index = 1
|
|
||||||
elseif(index>self.width)then index = self.width end
|
|
||||||
base.setValue(self, maxValue / self.width * (index))
|
|
||||||
elseif (barType == "vertical") then
|
|
||||||
if(index<1)then index = 1
|
|
||||||
elseif(index>self.height)then index = self.height end
|
|
||||||
base.setValue(self, maxValue / self.height * (index))
|
|
||||||
end
|
|
||||||
return self
|
|
||||||
end;
|
|
||||||
|
|
||||||
setIndex = function(self, _index)
|
|
||||||
if (barType == "horizontal") then
|
|
||||||
if(_index>=1)and(_index<=self.width)then
|
|
||||||
index = _index
|
|
||||||
base.setValue(self, maxValue / self.width * (index))
|
|
||||||
end
|
|
||||||
elseif(barType == "vertical") then
|
|
||||||
if(_index>=1)and(_index<=self.height)then
|
|
||||||
index = _index
|
|
||||||
base.setValue(self, maxValue / self.height * (index))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return self
|
|
||||||
end;
|
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
|
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
||||||
if (barType == "horizontal") then
|
if (barType == "horizontal") then
|
||||||
for _index = 0, self.width - 1 do
|
for _index = 0, self.width do
|
||||||
if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then
|
if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then
|
||||||
index = _index + 1
|
index = math.min(_index + 1, self.width - (symbolSize - 1))
|
||||||
base.setValue(self, maxValue / self.width * (index))
|
self:setValue(maxValue / self.width * (index))
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (barType == "vertical") then
|
if (barType == "vertical") then
|
||||||
for _index = 0, self.height - 1 do
|
for _index = 0, self.height do
|
||||||
if (oby + _index == y) and (obx <= x) and (obx + self.width > x) then
|
if (oby + _index == y) and (obx <= x) and (obx + self.width > x) then
|
||||||
index = _index + 1
|
index = math.min(_index + 1, self.height - (symbolSize - 1))
|
||||||
base.setValue(self, maxValue / self.height * (index))
|
self:setValue(maxValue / self.height * (index))
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--[[if(event=="mouse_scroll")then
|
|
||||||
self:setValue(self:getValue() + (maxValue/(barType=="vertical" and self.height or self.width))*typ)
|
|
||||||
self:setVisualChanged()
|
|
||||||
end
|
end
|
||||||
if(self:getValue()>maxValue)then self:setValue(maxValue) end
|
if (event == "mouse_scroll") then
|
||||||
if(self:getValue()<maxValue/(barType=="vertical" and self.height or self.width))then self:setValue(maxValue/(barType=="vertical" and self.height or self.width)) end
|
index = index + button
|
||||||
]]
|
if (index < 1) then
|
||||||
|
index = 1
|
||||||
|
end
|
||||||
|
index = math.min(index, (barType == "vertical" and self.height or self.width) - (symbolSize - 1))
|
||||||
|
self:setValue(maxValue / (barType == "vertical" and self.height or self.width) * index)
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -3367,23 +3374,28 @@ local function Slider(name)
|
|||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
if (barType == "horizontal") then
|
if (barType == "horizontal") then
|
||||||
self.parent:writeText(obx, oby, bgSymbol:rep(index - 1), self.bgColor, self.fgColor)
|
self.parent:writeText(obx, oby, bgSymbol:rep(index - 1), self.bgColor, self.fgColor)
|
||||||
self.parent:writeText(obx + index - 1, oby, symbol, symbolColor, symbolColor)
|
self.parent:writeText(obx + index - 1, oby, symbol:rep(symbolSize), symbolColor, symbolColor)
|
||||||
self.parent:writeText(obx + index, oby, bgSymbol:rep(self.width - (index)), self.bgColor, self.fgColor)
|
self.parent:writeText(obx + index + symbolSize - 1, oby, bgSymbol:rep(self.width - (index + symbolSize - 1)), self.bgColor, self.fgColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (barType == "vertical") then
|
if (barType == "vertical") then
|
||||||
for n = 0, self.height - 1 do
|
for n = 0, self.height - 1 do
|
||||||
if (n + 1 == index) then
|
|
||||||
self.parent:writeText(obx, oby + n, symbol, symbolColor, symbolColor)
|
if (index == n + 1) then
|
||||||
|
for curIndexOffset = 0, math.min(symbolSize - 1, self.height) do
|
||||||
|
self.parent:writeText(obx, oby + n + curIndexOffset, symbol, symbolColor, symbolColor)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
|
if (n + 1 < index) or (n + 1 > index - 1 + symbolSize) then
|
||||||
self.parent:writeText(obx, oby + n, bgSymbol, self.bgColor, self.fgColor)
|
self.parent:writeText(obx, oby + n, bgSymbol, self.bgColor, self.fgColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(object, base)
|
return setmetatable(object, base)
|
||||||
@@ -3422,6 +3434,7 @@ local function Switch(name)
|
|||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -3758,6 +3771,7 @@ local function Textfield(name)
|
|||||||
self.parent:setText(obx, oby + n - 1, text)
|
self.parent:setText(obx, oby + n - 1, text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -3841,6 +3855,7 @@ local function Timer(name)
|
|||||||
local repeats = 0
|
local repeats = 0
|
||||||
local timerObj
|
local timerObj
|
||||||
local eventSystem = BasaltEvents()
|
local eventSystem = BasaltEvents()
|
||||||
|
local timerIsActive = false
|
||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
name = name,
|
name = name,
|
||||||
@@ -3863,15 +3878,24 @@ local function Timer(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
start = function(self)
|
start = function(self)
|
||||||
|
if(timerIsActive)then
|
||||||
|
os.cancelTimer(timerObj)
|
||||||
|
end
|
||||||
repeats = savedRepeats
|
repeats = savedRepeats
|
||||||
timerObj = os.startTimer(timer)
|
timerObj = os.startTimer(timer)
|
||||||
|
timerIsActive = true
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
isActive = function(self)
|
||||||
|
return timerIsActive
|
||||||
|
end;
|
||||||
|
|
||||||
cancel = function(self)
|
cancel = function(self)
|
||||||
if (timerObj ~= nil) then
|
if (timerObj ~= nil) then
|
||||||
os.cancelTimer(timerObj)
|
os.cancelTimer(timerObj)
|
||||||
end
|
end
|
||||||
|
timerIsActive = false
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -3881,7 +3905,7 @@ local function Timer(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
eventHandler = function(self, event, tObj)
|
eventHandler = function(self, event, tObj)
|
||||||
if (event == "timer") and (tObj == timerObj) then
|
if event == "timer" and tObj == timerObj and timerIsActive then
|
||||||
eventSystem:sendEvent("timed_event", self)
|
eventSystem:sendEvent("timed_event", self)
|
||||||
if (repeats >= 1) then
|
if (repeats >= 1) then
|
||||||
repeats = repeats - 1
|
repeats = repeats - 1
|
||||||
@@ -4081,7 +4105,8 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
setFrameAsMonitor = function(self, isMon)
|
setFrameAsMonitor = function(self, isMon)
|
||||||
isMonitor = isMon or true
|
isMonitor = isMon
|
||||||
|
if(isMon==nil)then isMonitor = true end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -4317,11 +4342,11 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
if (self:getVisualChanged()) then
|
|
||||||
if (base.draw(self)) then
|
|
||||||
for _,v in pairs(monitors)do
|
for _,v in pairs(monitors)do
|
||||||
v.frame:draw()
|
v.frame:draw()
|
||||||
end
|
end
|
||||||
|
if (self:getVisualChanged()) then
|
||||||
|
if (base.draw(self)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
local anchx, anchy = self:getAnchorPosition()
|
local anchx, anchy = self:getAnchorPosition()
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
@@ -4333,7 +4358,7 @@ local function Frame(name, parent)
|
|||||||
drawHelper.drawForegroundBox(obx, oby, self.width, self.height, self.fgColor)
|
drawHelper.drawForegroundBox(obx, oby, self.width, self.height, self.fgColor)
|
||||||
drawHelper.drawTextBox(obx, oby, self.width, self.height, " ")
|
drawHelper.drawTextBox(obx, oby, self.width, self.height, " ")
|
||||||
end
|
end
|
||||||
parentTerminal.setCursorBlink(false)
|
termObject.setCursorBlink(false)
|
||||||
if (self.barActive) then
|
if (self.barActive) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:writeText(anchx, anchy, getTextHorizontalAlign(self.barText, self.width, self.barTextAlign), self.barBackground, self.barTextcolor)
|
self.parent:writeText(anchx, anchy, getTextHorizontalAlign(self.barText, self.width, self.barTextAlign), self.barBackground, self.barTextcolor)
|
||||||
@@ -4363,7 +4388,13 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
|
||||||
|
drawUpdate = function (self)
|
||||||
drawHelper.update()
|
drawHelper.update()
|
||||||
|
for k,v in pairs(monitors)do
|
||||||
|
v.frame:drawUpdate()
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -4387,7 +4418,6 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
addLabel = function(self, name)
|
addLabel = function(self, name)
|
||||||
local obj = Label(name)
|
local obj = Label(name)
|
||||||
obj.name = name
|
|
||||||
obj.bgColor = self.bgColor
|
obj.bgColor = self.bgColor
|
||||||
obj.fgColor = self.fgColor
|
obj.fgColor = self.fgColor
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
@@ -4395,103 +4425,87 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
addCheckbox = function(self, name)
|
addCheckbox = function(self, name)
|
||||||
local obj = Checkbox(name)
|
local obj = Checkbox(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addInput = function(self, name)
|
addInput = function(self, name)
|
||||||
local obj = Input(name)
|
local obj = Input(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addProgram = function(self, name)
|
addProgram = function(self, name)
|
||||||
local obj = Program(name)
|
local obj = Program(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addTextfield = function(self, name)
|
addTextfield = function(self, name)
|
||||||
local obj = Textfield(name)
|
local obj = Textfield(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addList = function(self, name)
|
addList = function(self, name)
|
||||||
local obj = List(name)
|
local obj = List(name)
|
||||||
obj.name = name
|
obj.name = nam
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addDropdown = function(self, name)
|
addDropdown = function(self, name)
|
||||||
local obj = Dropdown(name)
|
local obj = Dropdown(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addRadio = function(self, name)
|
addRadio = function(self, name)
|
||||||
local obj = Radio(name)
|
local obj = Radio(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addTimer = function(self, name)
|
addTimer = function(self, name)
|
||||||
local obj = Timer(name)
|
local obj = Timer(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addAnimation = function(self, name)
|
addAnimation = function(self, name)
|
||||||
local obj = Animation(name)
|
local obj = Animation(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addSlider = function(self, name)
|
addSlider = function(self, name)
|
||||||
local obj = Slider(name)
|
local obj = Slider(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addScrollbar = function(self, name)
|
addScrollbar = function(self, name)
|
||||||
local obj = Scrollbar(name)
|
local obj = Scrollbar(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addMenubar = function(self, name)
|
addMenubar = function(self, name)
|
||||||
local obj = Menubar(name)
|
local obj = Menubar(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addThread = function(self, name)
|
addThread = function(self, name)
|
||||||
local obj = Thread(name)
|
local obj = Thread(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addPane = function(self, name)
|
addPane = function(self, name)
|
||||||
local obj = Pane(name)
|
local obj = Pane(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addImage = function(self, name)
|
addImage = function(self, name)
|
||||||
local obj = Image(name)
|
local obj = Image(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addProgressbar = function(self, name)
|
addProgressbar = function(self, name)
|
||||||
local obj = Progressbar(name)
|
local obj = Progressbar(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addFrame = function(self, name)
|
addFrame = function(self, name)
|
||||||
local obj = Frame(name, self)
|
local obj = Frame(name, self)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
@@ -4531,6 +4545,7 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
|||||||
end
|
end
|
||||||
if (updaterActive) then
|
if (updaterActive) then
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
|
activeFrame:drawUpdate()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4538,6 +4553,7 @@ function basalt.autoUpdate(isActive)
|
|||||||
parentTerminal.clear()
|
parentTerminal.clear()
|
||||||
updaterActive = isActive or true
|
updaterActive = isActive or true
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
|
activeFrame:drawUpdate()
|
||||||
while updaterActive do
|
while updaterActive do
|
||||||
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
@@ -4545,10 +4561,11 @@ function basalt.autoUpdate(isActive)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function basalt.update(event, p1, p2, p3, p4)
|
function basalt.update(event, p1, p2, p3, p4)
|
||||||
if (event ~= "nil") then
|
if (event ~= nil) then
|
||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
else
|
else
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
|
activeFrame:drawUpdate()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4620,6 +4637,9 @@ if (basalt.debugger) then
|
|||||||
basalt.debugList:removeItem(1)
|
basalt.debugList:removeItem(1)
|
||||||
end
|
end
|
||||||
basalt.debugList:setValue(basalt.debugList:getItem(basalt.debugList:getItemCount()))
|
basalt.debugList:setValue(basalt.debugList:getItem(basalt.debugList:getItemCount()))
|
||||||
|
if(basalt.debugList.getItemCount() > basalt.debugList:getHeight())then
|
||||||
|
basalt.debugList:setIndexOffset(basalt.debugList:getItemCount() - basalt.debugList:getHeight())
|
||||||
|
end
|
||||||
basalt.debugLabel:show()
|
basalt.debugLabel:show()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -181,7 +181,8 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
setFrameAsMonitor = function(self, isMon)
|
setFrameAsMonitor = function(self, isMon)
|
||||||
isMonitor = isMon or true
|
isMonitor = isMon
|
||||||
|
if(isMon==nil)then isMonitor = true end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -417,11 +418,11 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
if (self:getVisualChanged()) then
|
|
||||||
if (base.draw(self)) then
|
|
||||||
for _,v in pairs(monitors)do
|
for _,v in pairs(monitors)do
|
||||||
v.frame:draw()
|
v.frame:draw()
|
||||||
end
|
end
|
||||||
|
if (self:getVisualChanged()) then
|
||||||
|
if (base.draw(self)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
local anchx, anchy = self:getAnchorPosition()
|
local anchx, anchy = self:getAnchorPosition()
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
@@ -433,7 +434,7 @@ local function Frame(name, parent)
|
|||||||
drawHelper.drawForegroundBox(obx, oby, self.width, self.height, self.fgColor)
|
drawHelper.drawForegroundBox(obx, oby, self.width, self.height, self.fgColor)
|
||||||
drawHelper.drawTextBox(obx, oby, self.width, self.height, " ")
|
drawHelper.drawTextBox(obx, oby, self.width, self.height, " ")
|
||||||
end
|
end
|
||||||
parentTerminal.setCursorBlink(false)
|
termObject.setCursorBlink(false)
|
||||||
if (self.barActive) then
|
if (self.barActive) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:writeText(anchx, anchy, getTextHorizontalAlign(self.barText, self.width, self.barTextAlign), self.barBackground, self.barTextcolor)
|
self.parent:writeText(anchx, anchy, getTextHorizontalAlign(self.barText, self.width, self.barTextAlign), self.barBackground, self.barTextcolor)
|
||||||
@@ -463,7 +464,13 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
|
||||||
|
drawUpdate = function (self)
|
||||||
drawHelper.update()
|
drawHelper.update()
|
||||||
|
for k,v in pairs(monitors)do
|
||||||
|
v.frame:drawUpdate()
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -487,7 +494,6 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
addLabel = function(self, name)
|
addLabel = function(self, name)
|
||||||
local obj = Label(name)
|
local obj = Label(name)
|
||||||
obj.name = name
|
|
||||||
obj.bgColor = self.bgColor
|
obj.bgColor = self.bgColor
|
||||||
obj.fgColor = self.fgColor
|
obj.fgColor = self.fgColor
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
@@ -495,103 +501,87 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
addCheckbox = function(self, name)
|
addCheckbox = function(self, name)
|
||||||
local obj = Checkbox(name)
|
local obj = Checkbox(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addInput = function(self, name)
|
addInput = function(self, name)
|
||||||
local obj = Input(name)
|
local obj = Input(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addProgram = function(self, name)
|
addProgram = function(self, name)
|
||||||
local obj = Program(name)
|
local obj = Program(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addTextfield = function(self, name)
|
addTextfield = function(self, name)
|
||||||
local obj = Textfield(name)
|
local obj = Textfield(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addList = function(self, name)
|
addList = function(self, name)
|
||||||
local obj = List(name)
|
local obj = List(name)
|
||||||
obj.name = name
|
obj.name = nam
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addDropdown = function(self, name)
|
addDropdown = function(self, name)
|
||||||
local obj = Dropdown(name)
|
local obj = Dropdown(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addRadio = function(self, name)
|
addRadio = function(self, name)
|
||||||
local obj = Radio(name)
|
local obj = Radio(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addTimer = function(self, name)
|
addTimer = function(self, name)
|
||||||
local obj = Timer(name)
|
local obj = Timer(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addAnimation = function(self, name)
|
addAnimation = function(self, name)
|
||||||
local obj = Animation(name)
|
local obj = Animation(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addSlider = function(self, name)
|
addSlider = function(self, name)
|
||||||
local obj = Slider(name)
|
local obj = Slider(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addScrollbar = function(self, name)
|
addScrollbar = function(self, name)
|
||||||
local obj = Scrollbar(name)
|
local obj = Scrollbar(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addMenubar = function(self, name)
|
addMenubar = function(self, name)
|
||||||
local obj = Menubar(name)
|
local obj = Menubar(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addThread = function(self, name)
|
addThread = function(self, name)
|
||||||
local obj = Thread(name)
|
local obj = Thread(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addPane = function(self, name)
|
addPane = function(self, name)
|
||||||
local obj = Pane(name)
|
local obj = Pane(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addImage = function(self, name)
|
addImage = function(self, name)
|
||||||
local obj = Image(name)
|
local obj = Image(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addProgressbar = function(self, name)
|
addProgressbar = function(self, name)
|
||||||
local obj = Progressbar(name)
|
local obj = Progressbar(name)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addFrame = function(self, name)
|
addFrame = function(self, name)
|
||||||
local obj = Frame(name, self)
|
local obj = Frame(name, self)
|
||||||
obj.name = name
|
|
||||||
return addObject(obj)
|
return addObject(obj)
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ local function Object(name)
|
|||||||
return isVisible
|
return isVisible
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getZIndex = function(self)
|
|
||||||
return zIndex;
|
|
||||||
end;
|
|
||||||
|
|
||||||
setFocus = function(self)
|
setFocus = function(self)
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setFocusedObject(self)
|
self.parent:setFocusedObject(self)
|
||||||
@@ -63,6 +59,10 @@ local function Object(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getZIndex = function(self)
|
||||||
|
return zIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
getType = function(self)
|
getType = function(self)
|
||||||
return objectType
|
return objectType
|
||||||
end;
|
end;
|
||||||
@@ -108,6 +108,7 @@ local function Object(name)
|
|||||||
|
|
||||||
setVisualChanged = function(self, change)
|
setVisualChanged = function(self, change)
|
||||||
visualsChanged = change or true
|
visualsChanged = change or true
|
||||||
|
if(change == nil)then visualsChanged = true end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
|||||||
end
|
end
|
||||||
if (updaterActive) then
|
if (updaterActive) then
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
|
activeFrame:drawUpdate()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ function basalt.autoUpdate(isActive)
|
|||||||
parentTerminal.clear()
|
parentTerminal.clear()
|
||||||
updaterActive = isActive or true
|
updaterActive = isActive or true
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
|
activeFrame:drawUpdate()
|
||||||
while updaterActive do
|
while updaterActive do
|
||||||
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
@@ -42,10 +44,11 @@ function basalt.autoUpdate(isActive)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function basalt.update(event, p1, p2, p3, p4)
|
function basalt.update(event, p1, p2, p3, p4)
|
||||||
if (event ~= "nil") then
|
if (event ~= nil) then
|
||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
else
|
else
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
|
activeFrame:drawUpdate()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -117,6 +120,9 @@ if (basalt.debugger) then
|
|||||||
basalt.debugList:removeItem(1)
|
basalt.debugList:removeItem(1)
|
||||||
end
|
end
|
||||||
basalt.debugList:setValue(basalt.debugList:getItem(basalt.debugList:getItemCount()))
|
basalt.debugList:setValue(basalt.debugList:getItem(basalt.debugList:getItemCount()))
|
||||||
|
if(basalt.debugList.getItemCount() > basalt.debugList:getHeight())then
|
||||||
|
basalt.debugList:setIndexOffset(basalt.debugList:getItemCount() - basalt.debugList:getHeight())
|
||||||
|
end
|
||||||
basalt.debugLabel:show()
|
basalt.debugLabel:show()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ local function Button(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ local function Checkbox(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ local function Dropdown(name)
|
|||||||
local dropdownH = 6
|
local dropdownH = 6
|
||||||
local closedSymbol = "\16"
|
local closedSymbol = "\16"
|
||||||
local openedSymbol = "\31"
|
local openedSymbol = "\31"
|
||||||
local state = 1
|
local isOpened = false
|
||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
getType = function(self)
|
getType = function(self)
|
||||||
@@ -95,7 +95,7 @@ local function Dropdown(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (state == 2) then
|
if (isOpened) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
||||||
|
|
||||||
@@ -130,9 +130,9 @@ local function Dropdown(name)
|
|||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(self, event, button, x, y)) then
|
||||||
state = 2
|
isOpened = true
|
||||||
else
|
else
|
||||||
state = 1
|
isOpened = false
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -141,20 +141,14 @@ local function Dropdown(name)
|
|||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
if (#list >= 1) then
|
local val = self:getValue()
|
||||||
if (self:getValue() ~= nil) then
|
local text = getTextHorizontalAlign((val~=nil and val.text or ""), self.width, align):sub(1, self.width - 1) .. (isOpened and openedSymbol or closedSymbol)
|
||||||
if (self:getValue().text ~= nil) then
|
self.parent:writeText(obx, oby, text, self.bgColor, self.fgColor)
|
||||||
if (state == 1) then
|
|
||||||
self.parent:writeText(obx, oby, getTextHorizontalAlign(self:getValue().text, self.width, align):sub(1, self.width - 1) .. closedSymbol, self.bgColor, self.fgColor)
|
if (isOpened) then
|
||||||
else
|
|
||||||
self.parent:writeText(obx, oby, getTextHorizontalAlign(self:getValue().text, self.width, align):sub(1, self.width - 1) .. openedSymbol, self.bgColor, self.fgColor)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (state == 2) then
|
|
||||||
for n = 1, dropdownH do
|
for n = 1, dropdownH do
|
||||||
if (list[n + yOffset] ~= nil) then
|
if (list[n + yOffset] ~= nil) then
|
||||||
if (list[n + yOffset] == self:getValue()) then
|
if (list[n + yOffset] == val) then
|
||||||
if (selectionColorActive) then
|
if (selectionColorActive) then
|
||||||
self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), itemSelectedBG, itemSelectedFG)
|
self.parent:writeText(obx, oby + n, getTextHorizontalAlign(list[n + yOffset].text, dropdownW, align), itemSelectedBG, itemSelectedFG)
|
||||||
else
|
else
|
||||||
@@ -167,7 +161,7 @@ local function Dropdown(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ local function Image(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ local function Input(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ local function Label(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ local function List(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,16 +15,20 @@ local function Menubar(name)
|
|||||||
local selectionColorActive = true
|
local selectionColorActive = true
|
||||||
local align = "left"
|
local align = "left"
|
||||||
local itemOffset = 0
|
local itemOffset = 0
|
||||||
local space = 2
|
local space = 1
|
||||||
local scrollable = false
|
local scrollable = false
|
||||||
|
|
||||||
local function maxScroll()
|
local function maxScroll()
|
||||||
local mScroll = 0
|
local mScroll = 0
|
||||||
local xPos = 1
|
local xPos = 0
|
||||||
for n = 1, #list do
|
for n = 1, #list do
|
||||||
if (xPos + list[n].text:len() + space * 2 > object.w) then
|
if (xPos + list[n].text:len() + space * 2 > object.width) then
|
||||||
|
if(xPos < object.width)then
|
||||||
|
mScroll = mScroll + (list[n].text:len() + space * 2-(object.width - xPos))
|
||||||
|
else
|
||||||
mScroll = mScroll + list[n].text:len() + space * 2
|
mScroll = mScroll + list[n].text:len() + space * 2
|
||||||
end
|
end
|
||||||
|
end
|
||||||
xPos = xPos + list[n].text:len() + space * 2
|
xPos = xPos + list[n].text:len() + space * 2
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -68,7 +72,7 @@ local function Menubar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setButtonOffset = function(self, offset)
|
setPositionOffset = function(self, offset)
|
||||||
itemOffset = offset or 0
|
itemOffset = offset or 0
|
||||||
if (itemOffset < 0) then
|
if (itemOffset < 0) then
|
||||||
itemOffset = 0
|
itemOffset = 0
|
||||||
@@ -81,8 +85,13 @@ local function Menubar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getPositionOffset = function(self)
|
||||||
|
return itemOffset
|
||||||
|
end;
|
||||||
|
|
||||||
setScrollable = function(self, scroll)
|
setScrollable = function(self, scroll)
|
||||||
scrollable = scroll
|
scrollable = scroll
|
||||||
|
if(scroll==nil)then scrollable = true end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -118,24 +127,22 @@ local function Menubar(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
|
if(base.mouseClickHandler(self, event, button, x, y))then
|
||||||
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then
|
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setFocusedObject(self)
|
self.parent:setFocusedObject(self)
|
||||||
end
|
end
|
||||||
if (event == "mouse_click") or (event == "monitor_touch") then
|
if (event == "mouse_click") or (event == "monitor_touch") then
|
||||||
local xPos = 1
|
local xPos = 0
|
||||||
for n = 1 + itemOffset, #list do
|
for n = 1, #list do
|
||||||
if (list[n] ~= nil) then
|
if (list[n] ~= nil) then
|
||||||
if (xPos + list[n].text:len() + space * 2 <= self.width) then
|
--if (xPos-1 + list[n].text:len() + space * 2 <= self.width) then
|
||||||
if (objX + (xPos - 1) <= x) and (objX + (xPos - 1) + list[n].text:len() + space * 2 > x) and (objY == y) then
|
if (objX + xPos <= x + itemOffset) and (objX + xPos + list[n].text:len() + (space*2) > x + itemOffset) and (objY == y) then
|
||||||
self:setValue(list[n])
|
self:setValue(list[n])
|
||||||
self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n])
|
self:getEventSystem():sendEvent(event, self, event, 0, x, y, list[n])
|
||||||
end
|
end
|
||||||
xPos = xPos + list[n].text:len() + space * 2
|
xPos = xPos + list[n].text:len() + space * 2
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -145,14 +152,17 @@ local function Menubar(name)
|
|||||||
if (itemOffset < 0) then
|
if (itemOffset < 0) then
|
||||||
itemOffset = 0
|
itemOffset = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local mScroll = maxScroll()
|
local mScroll = maxScroll()
|
||||||
|
|
||||||
if (itemOffset > mScroll) then
|
if (itemOffset > mScroll) then
|
||||||
itemOffset = mScroll
|
itemOffset = mScroll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(true)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -161,27 +171,26 @@ local function Menubar(name)
|
|||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
local xPos = 0
|
local text = ""
|
||||||
for _, value in pairs(list) do
|
local textBGCol = ""
|
||||||
if (xPos + value.text:len() + space * 2 <= self.width) then
|
local textFGCol = ""
|
||||||
if (value == self:getValue()) then
|
for _, v in pairs(list) do
|
||||||
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align), itemSelectedBG or value.bgCol, itemSelectedFG or value.fgCol)
|
local newItem = (" "):rep(space) .. v.text .. (" "):rep(space)
|
||||||
|
text = text .. newItem
|
||||||
|
if(v == self:getValue())then
|
||||||
|
textBGCol = textBGCol .. tHex[itemSelectedBG or v.bgCol or self.bgColor]:rep(newItem:len())
|
||||||
|
textFGCol = textFGCol .. tHex[itemSelectedFG or v.FgCol or self.fgColor]:rep(newItem:len())
|
||||||
else
|
else
|
||||||
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align), value.bgCol, value.fgCol)
|
textBGCol = textBGCol .. tHex[v.bgCol or self.bgColor]:rep(newItem:len())
|
||||||
end
|
textFGCol = textFGCol .. tHex[v.FgCol or self.fgColor]:rep(newItem:len())
|
||||||
xPos = xPos + value.text:len() + space * 2
|
|
||||||
else
|
|
||||||
if (xPos < self.width + itemOffset) then
|
|
||||||
if (value == self:getValue()) then
|
|
||||||
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align):sub(1, self.width + itemOffset - xPos), itemSelectedBG or value.bgCol, itemSelectedFG or value.fgCol)
|
|
||||||
else
|
|
||||||
self.parent:writeText(obx + (xPos - 1) + (-itemOffset), oby, getTextHorizontalAlign((" "):rep(space) .. value.text .. (" "):rep(space), value.text:len() + space * 2, align):sub(1, self.width + itemOffset - xPos), value.bgCol, value.fgCol)
|
|
||||||
end
|
|
||||||
xPos = xPos + value.text:len() + space * 2
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.parent:setText(obx, oby, text:sub(itemOffset+1, self.width+itemOffset))
|
||||||
|
self.parent:setBG(obx, oby, textBGCol:sub(itemOffset+1, self.width+itemOffset))
|
||||||
|
self.parent:setFG(obx, oby, textFGCol:sub(itemOffset+1, self.width+itemOffset))
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ local function Pane(name)
|
|||||||
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
self.parent:drawForegroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawForegroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -633,6 +633,7 @@ local function Program(name)
|
|||||||
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
pWindow.basalt_update()
|
pWindow.basalt_update()
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ local function Progressbar(name)
|
|||||||
self.parent:drawTextBox(obx, oby, self.width / 100 * progress, self.height, activeBarSymbol)
|
self.parent:drawTextBox(obx, oby, self.width / 100 * progress, self.height, activeBarSymbol)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ local function Radio(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ local function Scrollbar(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local function Slider(name)
|
|||||||
local objectType = "Slider"
|
local objectType = "Slider"
|
||||||
|
|
||||||
base.width = 8
|
base.width = 8
|
||||||
|
base.height = 1
|
||||||
base.bgColor = colors.lightGray
|
base.bgColor = colors.lightGray
|
||||||
base.fgColor = colors.gray
|
base.fgColor = colors.gray
|
||||||
base:setValue(1)
|
base:setValue(1)
|
||||||
@@ -13,6 +14,7 @@ local function Slider(name)
|
|||||||
local bgSymbol = "\140"
|
local bgSymbol = "\140"
|
||||||
local maxValue = base.width
|
local maxValue = base.width
|
||||||
local index = 1
|
local index = 1
|
||||||
|
local symbolSize = 1
|
||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
getType = function(self)
|
getType = function(self)
|
||||||
@@ -25,6 +27,22 @@ local function Slider(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
setSymbolSize = function(self, size)
|
||||||
|
symbolSize = tonumber(size) or 1
|
||||||
|
if (barType == "vertical") then
|
||||||
|
self:setValue(index - 1 * (maxValue / (self.height - (symbolSize - 1))) - (maxValue / (self.height - (symbolSize - 1))))
|
||||||
|
elseif (barType == "horizontal") then
|
||||||
|
self:setValue(index - 1 * (maxValue / (self.width - (symbolSize - 1))) - (maxValue / (self.width - (symbolSize - 1))))
|
||||||
|
end
|
||||||
|
self:setVisualChanged()
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
setMaxValue = function(self, val)
|
||||||
|
maxValue = val
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
setBackgroundSymbol = function(self, _bgSymbol)
|
setBackgroundSymbol = function(self, _bgSymbol)
|
||||||
bgSymbol = string.sub(_bgSymbol, 1, 1)
|
bgSymbol = string.sub(_bgSymbol, 1, 1)
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
@@ -42,63 +60,38 @@ local function Slider(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setValue = function(self, val)
|
|
||||||
index = math.floor(val / maxValue)
|
|
||||||
if (barType == "horizontal") then
|
|
||||||
if(index<1)then index = 1
|
|
||||||
elseif(index>self.width)then index = self.width end
|
|
||||||
base.setValue(self, maxValue / self.width * (index))
|
|
||||||
elseif (barType == "vertical") then
|
|
||||||
if(index<1)then index = 1
|
|
||||||
elseif(index>self.height)then index = self.height end
|
|
||||||
base.setValue(self, maxValue / self.height * (index))
|
|
||||||
end
|
|
||||||
return self
|
|
||||||
end;
|
|
||||||
|
|
||||||
setIndex = function(self, _index)
|
|
||||||
if (barType == "horizontal") then
|
|
||||||
if(_index>=1)and(_index<=self.width)then
|
|
||||||
index = _index
|
|
||||||
base.setValue(self, maxValue / self.width * (index))
|
|
||||||
end
|
|
||||||
elseif(barType == "vertical") then
|
|
||||||
if(_index>=1)and(_index<=self.height)then
|
|
||||||
index = _index
|
|
||||||
base.setValue(self, maxValue / self.height * (index))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return self
|
|
||||||
end;
|
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
|
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
||||||
if (barType == "horizontal") then
|
if (barType == "horizontal") then
|
||||||
for _index = 0, self.width - 1 do
|
for _index = 0, self.width do
|
||||||
if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then
|
if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then
|
||||||
index = _index + 1
|
index = math.min(_index + 1, self.width - (symbolSize - 1))
|
||||||
base.setValue(self, maxValue / self.width * (index))
|
self:setValue(maxValue / self.width * (index))
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (barType == "vertical") then
|
if (barType == "vertical") then
|
||||||
for _index = 0, self.height - 1 do
|
for _index = 0, self.height do
|
||||||
if (oby + _index == y) and (obx <= x) and (obx + self.width > x) then
|
if (oby + _index == y) and (obx <= x) and (obx + self.width > x) then
|
||||||
index = _index + 1
|
index = math.min(_index + 1, self.height - (symbolSize - 1))
|
||||||
base.setValue(self, maxValue / self.height * (index))
|
self:setValue(maxValue / self.height * (index))
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--[[if(event=="mouse_scroll")then
|
|
||||||
self:setValue(self:getValue() + (maxValue/(barType=="vertical" and self.height or self.width))*typ)
|
|
||||||
self:setVisualChanged()
|
|
||||||
end
|
end
|
||||||
if(self:getValue()>maxValue)then self:setValue(maxValue) end
|
if (event == "mouse_scroll") then
|
||||||
if(self:getValue()<maxValue/(barType=="vertical" and self.height or self.width))then self:setValue(maxValue/(barType=="vertical" and self.height or self.width)) end
|
index = index + button
|
||||||
]]
|
if (index < 1) then
|
||||||
|
index = 1
|
||||||
|
end
|
||||||
|
index = math.min(index, (barType == "vertical" and self.height or self.width) - (symbolSize - 1))
|
||||||
|
self:setValue(maxValue / (barType == "vertical" and self.height or self.width) * index)
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -108,23 +101,28 @@ local function Slider(name)
|
|||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
if (barType == "horizontal") then
|
if (barType == "horizontal") then
|
||||||
self.parent:writeText(obx, oby, bgSymbol:rep(index - 1), self.bgColor, self.fgColor)
|
self.parent:writeText(obx, oby, bgSymbol:rep(index - 1), self.bgColor, self.fgColor)
|
||||||
self.parent:writeText(obx + index - 1, oby, symbol, symbolColor, symbolColor)
|
self.parent:writeText(obx + index - 1, oby, symbol:rep(symbolSize), symbolColor, symbolColor)
|
||||||
self.parent:writeText(obx + index, oby, bgSymbol:rep(self.width - (index)), self.bgColor, self.fgColor)
|
self.parent:writeText(obx + index + symbolSize - 1, oby, bgSymbol:rep(self.width - (index + symbolSize - 1)), self.bgColor, self.fgColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (barType == "vertical") then
|
if (barType == "vertical") then
|
||||||
for n = 0, self.height - 1 do
|
for n = 0, self.height - 1 do
|
||||||
if (n + 1 == index) then
|
|
||||||
self.parent:writeText(obx, oby + n, symbol, symbolColor, symbolColor)
|
if (index == n + 1) then
|
||||||
|
for curIndexOffset = 0, math.min(symbolSize - 1, self.height) do
|
||||||
|
self.parent:writeText(obx, oby + n + curIndexOffset, symbol, symbolColor, symbolColor)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
|
if (n + 1 < index) or (n + 1 > index - 1 + symbolSize) then
|
||||||
self.parent:writeText(obx, oby + n, bgSymbol, self.bgColor, self.fgColor)
|
self.parent:writeText(obx, oby + n, bgSymbol, self.bgColor, self.fgColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(object, base)
|
return setmetatable(object, base)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ local function Switch(name)
|
|||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ local function Textfield(name)
|
|||||||
self.parent:setText(obx, oby + n - 1, text)
|
self.parent:setText(obx, oby + n - 1, text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local function Timer(name)
|
|||||||
local repeats = 0
|
local repeats = 0
|
||||||
local timerObj
|
local timerObj
|
||||||
local eventSystem = BasaltEvents()
|
local eventSystem = BasaltEvents()
|
||||||
|
local timerIsActive = false
|
||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
name = name,
|
name = name,
|
||||||
@@ -28,15 +29,24 @@ local function Timer(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
start = function(self)
|
start = function(self)
|
||||||
|
if(timerIsActive)then
|
||||||
|
os.cancelTimer(timerObj)
|
||||||
|
end
|
||||||
repeats = savedRepeats
|
repeats = savedRepeats
|
||||||
timerObj = os.startTimer(timer)
|
timerObj = os.startTimer(timer)
|
||||||
|
timerIsActive = true
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
isActive = function(self)
|
||||||
|
return timerIsActive
|
||||||
|
end;
|
||||||
|
|
||||||
cancel = function(self)
|
cancel = function(self)
|
||||||
if (timerObj ~= nil) then
|
if (timerObj ~= nil) then
|
||||||
os.cancelTimer(timerObj)
|
os.cancelTimer(timerObj)
|
||||||
end
|
end
|
||||||
|
timerIsActive = false
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -46,7 +56,7 @@ local function Timer(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
eventHandler = function(self, event, tObj)
|
eventHandler = function(self, event, tObj)
|
||||||
if (event == "timer") and (tObj == timerObj) then
|
if event == "timer" and tObj == timerObj and timerIsActive then
|
||||||
eventSystem:sendEvent("timed_event", self)
|
eventSystem:sendEvent("timed_event", self)
|
||||||
if (repeats >= 1) then
|
if (repeats >= 1) then
|
||||||
repeats = repeats - 1
|
repeats = repeats - 1
|
||||||
|
|||||||
Reference in New Issue
Block a user