Basalt2 update

- Finished themes
- Added state plugins for persistance
- Finished reactive plugin
- Added debug plugin (80% finished)
- Added benchmark plugin
- Added Tree, Table, List, Dropdown and Menu Elements
- Bugfixes
This commit is contained in:
Robert Jelic
2025-02-15 18:18:49 +01:00
parent 8ea3ca2465
commit db716636bd
32 changed files with 1700 additions and 165 deletions

View File

@@ -44,9 +44,9 @@ function Container:isChildVisible(child)
local childW, childH = child.get("width"), child.get("height")
local containerW, containerH = self.get("width"), self.get("height")
return childX <= containerW and
childY <= containerH and
childX + childW > 0 and
return childX <= containerW and
childY <= containerH and
childX + childW > 0 and
childY + childH > 0
end
@@ -94,7 +94,7 @@ local function sortAndFilterChildren(self, children)
local visibleChildren = {}
for _, child in ipairs(children) do
if self:isChildVisible(child) then
if self:isChildVisible(child) and child.get("visible") then
table.insert(visibleChildren, child)
end
end
@@ -103,7 +103,6 @@ local function sortAndFilterChildren(self, children)
local current = visibleChildren[i]
local currentZ = current.get("z")
local j = i - 1
while j > 0 do
local compare = visibleChildren[j].get("z")
if compare > currentZ then
@@ -119,6 +118,15 @@ local function sortAndFilterChildren(self, children)
return visibleChildren
end
function Container:clear()
self.set("children", {})
self.set("childrenEvents", {})
self.set("visibleChildren", {})
self.set("visibleChildrenEvents", {})
self.set("childrenSorted", true)
self.set("childrenEventsSorted", true)
end
function Container:sortChildren()
self.set("visibleChildren", sortAndFilterChildren(self, self._values.children))
self.set("childrenSorted", true)
@@ -234,7 +242,7 @@ local function callChildrenEvents(self, visibleOnly, event, ...)
for i = #events, 1, -1 do
local child = events[i]
if(child:dispatchEvent(event, ...))then
return true, child
return true, child
end
end
end
@@ -242,12 +250,12 @@ local function callChildrenEvents(self, visibleOnly, event, ...)
end
function Container:handleEvent(event, ...)
if(VisualElement.handleEvent(self, event, ...))then
local args = convertMousePosition(self, event, ...)
return callChildrenEvents(self, false, event, table.unpack(args))
end
VisualElement.handleEvent(self, event, ...)
local args = convertMousePosition(self, event, ...)
return callChildrenEvents(self, false, event, table.unpack(args))
end
function Container:mouse_click(button, x, y)
if VisualElement.mouse_click(self, button, x, y) then
local args = convertMousePosition(self, "mouse_click", button, x, y)
@@ -260,6 +268,16 @@ function Container:mouse_click(button, x, y)
end
end
function Container:mouse_up(button, x, y)
if VisualElement.mouse_up(self, button, x, y) then
local args = convertMousePosition(self, "mouse_up", button, x, y)
local success, child = callChildrenEvents(self, true, "mouse_up", table.unpack(args))
if(success)then
return true
end
end
end
function Container:key(key)
if self.get("focusedChild") then
return self.get("focusedChild"):dispatchEvent("key", key)