Small improvements
- added term_resize event for craft os pc - added auto resize on baseframe until you use :setSize() - added auto max. scrollheight (it will be automatically calculated based on the frames children positions) you can cancel that when using :setMaxScroll()
This commit is contained in:
@@ -30,7 +30,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
local dragYOffset = 0
|
local dragYOffset = 0
|
||||||
local isScrollable = false
|
local isScrollable = false
|
||||||
local minScroll = 0
|
local minScroll = 0
|
||||||
local maxScroll = 10
|
local maxScroll = 0
|
||||||
local mirrorActive = false
|
local mirrorActive = false
|
||||||
local mirrorAttached = false
|
local mirrorAttached = false
|
||||||
local mirrorSide = ""
|
local mirrorSide = ""
|
||||||
@@ -38,6 +38,8 @@ return function(name, parent, pTerm, basalt)
|
|||||||
|
|
||||||
local focusedOBjectCache
|
local focusedOBjectCache
|
||||||
local focusedObject
|
local focusedObject
|
||||||
|
local autoSize = true
|
||||||
|
local autoScroll = true
|
||||||
|
|
||||||
base:setZIndex(10)
|
base:setZIndex(10)
|
||||||
|
|
||||||
@@ -225,6 +227,9 @@ return function(name, parent, pTerm, basalt)
|
|||||||
if(#dynamicValues[n][3]<=0)then dynamicValues[n][3] = dynValueGetObjects(dynamicValues[n][4], dynamicValues[n][2]) end
|
if(#dynamicValues[n][3]<=0)then dynamicValues[n][3] = dynValueGetObjects(dynamicValues[n][4], dynamicValues[n][2]) end
|
||||||
numberStr = dynValueObjectToNumber(dynamicValues[n][2], dynamicValues[n][3])
|
numberStr = dynValueObjectToNumber(dynamicValues[n][2], dynamicValues[n][3])
|
||||||
dynamicValues[n][1] = stringToNumber(numberStr)
|
dynamicValues[n][1] = stringToNumber(numberStr)
|
||||||
|
if(dynamicValues[n][4]:getType()=="Frame")then
|
||||||
|
dynamicValues[n][4]:recalculateDynamicValues()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -234,6 +239,17 @@ return function(name, parent, pTerm, basalt)
|
|||||||
return dynamicValues[id][1]
|
return dynamicValues[id][1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function calculateMaxScroll(self)
|
||||||
|
for _, value in pairs(objects) do
|
||||||
|
for _, b in pairs(value) do
|
||||||
|
local h, y = b:getHeight(), b:getY()
|
||||||
|
if (h + y > maxScroll) then
|
||||||
|
maxScroll = math.max((h + y) - self:getHeight(), 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
object = {
|
object = {
|
||||||
barActive = false,
|
barActive = false,
|
||||||
@@ -262,6 +278,9 @@ return function(name, parent, pTerm, basalt)
|
|||||||
|
|
||||||
setSize = function(self, w, h, rel)
|
setSize = function(self, w, h, rel)
|
||||||
base.setSize(self, w, h, rel)
|
base.setSize(self, w, h, rel)
|
||||||
|
if(self.parent==nil)then
|
||||||
|
basaltDraw = BasaltDraw()
|
||||||
|
end
|
||||||
for _, index in pairs(objZIndex) do
|
for _, index in pairs(objZIndex) do
|
||||||
if (objects[index] ~= nil) then
|
if (objects[index] ~= nil) then
|
||||||
for _, value in pairs(objects[index]) do
|
for _, value in pairs(objects[index]) do
|
||||||
@@ -271,6 +290,8 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
recalculateDynamicValues()
|
||||||
|
autoSize = false
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -361,6 +382,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
|
|
||||||
setMaxScroll = function(self, max)
|
setMaxScroll = function(self, max)
|
||||||
maxScroll = max or maxScroll
|
maxScroll = max or maxScroll
|
||||||
|
autoScroll = false
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -519,6 +541,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
basalt.setMonitorFrame(monSide, nil)
|
basalt.setMonitorFrame(monSide, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:setSize(termObject.getSize())
|
||||||
basaltDraw = BasaltDraw(termObject)
|
basaltDraw = BasaltDraw(termObject)
|
||||||
monSide = side or nil
|
monSide = side or nil
|
||||||
return self;
|
return self;
|
||||||
@@ -593,6 +616,14 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if(autoSize)then
|
||||||
|
if(self.parent==nil)then
|
||||||
|
if(event=="term_resize")then
|
||||||
|
self:setSize(termObject.getSize())
|
||||||
|
autoSize = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if(isMonitor)then
|
if(isMonitor)then
|
||||||
if(event == "peripheral")and(p1==monSide)then
|
if(event == "peripheral")and(p1==monSide)then
|
||||||
if(peripheral.getType(monSide)=="monitor")then
|
if(peripheral.getType(monSide)=="monitor")then
|
||||||
@@ -655,6 +686,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
if(isScrollable)and(importantScroll)then
|
if(isScrollable)and(importantScroll)then
|
||||||
if(event=="mouse_scroll")then
|
if(event=="mouse_scroll")then
|
||||||
if(button>0)or(button<0)then
|
if(button>0)or(button<0)then
|
||||||
|
if(autoScroll)then calculateMaxScroll(self) end
|
||||||
yOffset = max(min(yOffset-button, -minScroll),-maxScroll)
|
yOffset = max(min(yOffset-button, -minScroll),-maxScroll)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -681,6 +713,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
if(isScrollable)and(not importantScroll)then
|
if(isScrollable)and(not importantScroll)then
|
||||||
if(event=="mouse_scroll")then
|
if(event=="mouse_scroll")then
|
||||||
if(button>0)or(button<0)then
|
if(button>0)or(button<0)then
|
||||||
|
if(autoScroll)then calculateMaxScroll(self) end
|
||||||
yOffset = max(min(yOffset-button, -minScroll),-maxScroll)
|
yOffset = max(min(yOffset-button, -minScroll),-maxScroll)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -206,10 +206,6 @@ return function(name)
|
|||||||
return self.parent
|
return self.parent
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getObjectReferencesForDynVal = function(self, str)
|
|
||||||
|
|
||||||
end,
|
|
||||||
|
|
||||||
setPosition = function(self, xPos, yPos, rel)
|
setPosition = function(self, xPos, yPos, rel)
|
||||||
if(type(xPos)=="number")then
|
if(type(xPos)=="number")then
|
||||||
self.x = rel and self:getX()+xPos or xPos
|
self.x = rel and self:getX()+xPos or xPos
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ return function(drawTerm)
|
|||||||
createEmptyLines()
|
createEmptyLines()
|
||||||
|
|
||||||
local function recreateWindowArray()
|
local function recreateWindowArray()
|
||||||
|
createEmptyLines()
|
||||||
local emptyText = emptySpaceLine
|
local emptyText = emptySpaceLine
|
||||||
local emptyFG = emptyColorLines[colors.white]
|
local emptyFG = emptyColorLines[colors.white]
|
||||||
local emptyBG = emptyColorLines[colors.black]
|
local emptyBG = emptyColorLines[colors.black]
|
||||||
@@ -126,6 +127,11 @@ return function(drawTerm)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local drawHelper = {
|
local drawHelper = {
|
||||||
|
setSize = function(w, h)
|
||||||
|
width, height = w, h
|
||||||
|
recreateWindowArray()
|
||||||
|
end,
|
||||||
|
|
||||||
setMirror = function(mirror)
|
setMirror = function(mirror)
|
||||||
mirrorTerm = mirror
|
mirrorTerm = mirror
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
|||||||
activeKey[p1] = false
|
activeKey[p1] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in pairs(frames) do
|
for k, v in pairs(frames) do
|
||||||
v:eventHandler(event, p1, p2, p3, p4)
|
v:eventHandler(event, p1, p2, p3, p4)
|
||||||
end
|
end
|
||||||
handleSchedules(event, p1, p2, p3, p4)
|
handleSchedules(event, p1, p2, p3, p4)
|
||||||
@@ -339,7 +339,7 @@ basalt = {
|
|||||||
|
|
||||||
basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray)
|
basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray)
|
||||||
basalt.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1, 1):setText("\22"):onClick(function() if(basalt.oldFrame~=nil)then basalt.oldFrame:show() end end):setBackground(colors.red):show()
|
basalt.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1, 1):setText("\22"):onClick(function() if(basalt.oldFrame~=nil)then basalt.oldFrame:show() end end):setBackground(colors.red):show()
|
||||||
basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.width - 2, basalt.debugFrame.height - 3):setPosition(2, 3):setScrollable(true):show()
|
basalt.debugList = basalt.debugFrame:addList("debugList"):setSize("parent.w - 2", "parent.h - 3"):setPosition(2, 3):setScrollable(true):show()
|
||||||
basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = mainFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()
|
basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = mainFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()
|
||||||
|
|
||||||
return basalt
|
return basalt
|
||||||
|
|||||||
Reference in New Issue
Block a user