Class rename

This commit is contained in:
Robert Jelic
2025-09-14 12:19:36 +02:00
parent dd6a1209a1
commit 264b1b9425
5 changed files with 81 additions and 81 deletions

View File

@@ -1378,7 +1378,7 @@ self:textFg(1,y,
bd..string.rep(" ",self.get("width")-#bd),self.get("foreground"))else
self:textFg(1,y,string.rep(" ",self.get("width")),self.get("foreground"),self.get("background"))end end end;return ba end
project["elements/ComboBox.lua"] = function(...) local _a=require("elements/VisualElement")
local aa=require("elements/Dropdown")local ba=require("libraries/colorHex")
local aa=require("src.elements.DropDown")local ba=require("libraries/colorHex")
local ca=setmetatable({},aa)ca.__index=ca
ca.defineProperty(ca,"editable",{default=true,type="boolean",canTriggerRender=true})
ca.defineProperty(ca,"text",{default="",type="string",canTriggerRender=true})

View File

@@ -1,15 +1,15 @@
local VisualElement = require("elements/VisualElement")
---@cofnigDescription This is a checkbox. It is a visual element that can be checked.
--- The Checkbox is a visual element that can be checked.
---@class Checkbox : VisualElement
local Checkbox = setmetatable({}, VisualElement)
Checkbox.__index = Checkbox
--- The CheckBox is a visual element that can be checked.
---@class CheckBox : VisualElement
local CheckBox = setmetatable({}, VisualElement)
CheckBox.__index = CheckBox
---@property checked boolean Whether checkbox is checked
Checkbox.defineProperty(Checkbox, "checked", {default = false, type = "boolean", canTriggerRender = true})
CheckBox.defineProperty(CheckBox, "checked", {default = false, type = "boolean", canTriggerRender = true})
---@property text string empty Text to display
Checkbox.defineProperty(Checkbox, "text", {default = " ", type = "string", canTriggerRender = true, setter=function(self, value)
CheckBox.defineProperty(CheckBox, "text", {default = " ", type = "string", canTriggerRender = true, setter=function(self, value)
local checkedText = self.get("checkedText")
local width = math.max(#value, #checkedText)
if(self.get("autoSize"))then
@@ -18,7 +18,7 @@ Checkbox.defineProperty(Checkbox, "text", {default = " ", type = "string", canTr
return value
end})
---@property checkedText string Text when checked
Checkbox.defineProperty(Checkbox, "checkedText", {default = "x", type = "string", canTriggerRender = true, setter=function(self, value)
CheckBox.defineProperty(CheckBox, "checkedText", {default = "x", type = "string", canTriggerRender = true, setter=function(self, value)
local text = self.get("text")
local width = math.max(#value, #text)
if(self.get("autoSize"))then
@@ -27,28 +27,28 @@ Checkbox.defineProperty(Checkbox, "checkedText", {default = "x", type = "string"
return value
end})
---@property autoSize boolean true Whether to automatically size the checkbox
Checkbox.defineProperty(Checkbox, "autoSize", {default = true, type = "boolean"})
CheckBox.defineProperty(CheckBox, "autoSize", {default = true, type = "boolean"})
Checkbox.defineEvent(Checkbox, "mouse_click")
Checkbox.defineEvent(Checkbox, "mouse_up")
CheckBox.defineEvent(CheckBox, "mouse_click")
CheckBox.defineEvent(CheckBox, "mouse_up")
--- @shortDescription Creates a new Checkbox instance
--- @return Checkbox self The created instance
--- @shortDescription Creates a new CheckBox instance
--- @return CheckBox self The created instance
--- @protected
function Checkbox.new()
local self = setmetatable({}, Checkbox):__init()
self.class = Checkbox
function CheckBox.new()
local self = setmetatable({}, CheckBox):__init()
self.class = CheckBox
self.set("backgroundEnabled", false)
return self
end
--- @shortDescription Initializes the Checkbox instance
--- @shortDescription Initializes the CheckBox instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @protected
function Checkbox:init(props, basalt)
function CheckBox:init(props, basalt)
VisualElement.init(self, props, basalt)
self.set("type", "Checkbox")
self.set("type", "CheckBox")
end
--- @shortDescription Handles mouse click events
@@ -57,7 +57,7 @@ end
--- @param y number The y position of the click
--- @return boolean Clicked Whether the event was handled
--- @protected
function Checkbox:mouse_click(button, x, y)
function CheckBox:mouse_click(button, x, y)
if VisualElement.mouse_click(self, button, x, y) then
self.set("checked", not self.get("checked"))
return true
@@ -65,9 +65,9 @@ function Checkbox:mouse_click(button, x, y)
return false
end
--- @shortDescription Renders the Checkbox
--- @shortDescription Renders the CheckBox
--- @protected
function Checkbox:render()
function CheckBox:render()
VisualElement.render(self)
local checked = self.get("checked")
@@ -78,4 +78,4 @@ function Checkbox:render()
self:textFg(1, 1, text, self.get("foreground"))
end
return Checkbox
return CheckBox

View File

@@ -1,5 +1,5 @@
local VisualElement = require("elements/VisualElement")
local Dropdown = require("elements/Dropdown")
local Dropdown = require("src.elements.DropDown")
local tHex = require("libraries/colorHex")
---@configDescription A ComboBox that combines dropdown selection with editable text input

View File

@@ -2,50 +2,50 @@ local VisualElement = require("elements/VisualElement")
local List = require("elements/List")
local tHex = require("libraries/colorHex")
---@configDescription A dropdown menu that shows a list of selectable items
---@configDescription A DropDown menu that shows a list of selectable items
---@configDefault false
--- This is the dropdown class. It is a visual element that can show a list of selectable items in a dropdown menu.
--- @usage local dropdown = main:addDropdown()
--- @usage dropdown:setItems({
--- This is the DropDown class. It is a visual element that can show a list of selectable items in a DropDown menu.
--- @usage local DropDown = main:addDropdown()
--- @usage DropDown:setItems({
--- @usage {text = "Item 1", callback = function() basalt.LOGGER.debug("Item 1 selected") end},
--- @usage {text = "Item 2", callback = function() basalt.LOGGER.debug("Item 2 selected") end},
--- @usage {text = "Item 3", callback = function() basalt.LOGGER.debug("Item 3 selected") end},
--- @usage })
---@class Dropdown : List
local Dropdown = setmetatable({}, List)
Dropdown.__index = Dropdown
---@class DropDown : List
local DropDown = setmetatable({}, List)
DropDown.__index = DropDown
---@property isOpen boolean false Whether the dropdown menu is currently open
Dropdown.defineProperty(Dropdown, "isOpen", {default = false, type = "boolean", canTriggerRender = true})
---@property dropdownHeight number 5 Maximum height of the dropdown menu when open
Dropdown.defineProperty(Dropdown, "dropdownHeight", {default = 5, type = "number"})
---@property isOpen boolean false Whether the DropDown menu is currently open
DropDown.defineProperty(DropDown, "isOpen", {default = false, type = "boolean", canTriggerRender = true})
---@property dropdownHeight number 5 Maximum height of the DropDown menu when open
DropDown.defineProperty(DropDown, "dropdownHeight", {default = 5, type = "number"})
---@property selectedText string "" The text to show when no item is selected
Dropdown.defineProperty(Dropdown, "selectedText", {default = "", type = "string"})
---@property dropSymbol string "\31" The symbol to show for dropdown indication
Dropdown.defineProperty(Dropdown, "dropSymbol", {default = "\31", type = "string"})
DropDown.defineProperty(DropDown, "selectedText", {default = "", type = "string"})
---@property dropSymbol string "\31" The symbol to show for DropDown indication
DropDown.defineProperty(DropDown, "dropSymbol", {default = "\31", type = "string"})
--- Creates a new Dropdown instance
--- @shortDescription Creates a new Dropdown instance
--- @return Dropdown self The newly created Dropdown instance
--- Creates a new DropDown instance
--- @shortDescription Creates a new DropDown instance
--- @return DropDown self The newly created DropDown instance
--- @private
function Dropdown.new()
local self = setmetatable({}, Dropdown):__init()
self.class = Dropdown
function DropDown.new()
local self = setmetatable({}, DropDown):__init()
self.class = DropDown
self.set("width", 16)
self.set("height", 1)
self.set("z", 8)
return self
end
--- @shortDescription Initializes the Dropdown instance
--- @shortDescription Initializes the DropDown instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @return Dropdown self The initialized instance
--- @return DropDown self The initialized instance
--- @protected
function Dropdown:init(props, basalt)
function DropDown:init(props, basalt)
List.init(self, props, basalt)
self.set("type", "Dropdown")
self.set("type", "DropDown")
return self
end
@@ -55,7 +55,7 @@ end
--- @param y number The y position of the click
--- @return boolean handled Whether the event was handled
--- @protected
function Dropdown:mouse_click(button, x, y)
function DropDown:mouse_click(button, x, y)
if not VisualElement.mouse_click(self, button, x, y) then return false end
local relX, relY = self:getRelativePosition(x, y)
@@ -103,9 +103,9 @@ function Dropdown:mouse_click(button, x, y)
return false
end
--- @shortDescription Renders the Dropdown
--- @shortDescription Renders the DropDown
--- @protected
function Dropdown:render()
function DropDown:render()
VisualElement.render(self)
local text = self.get("selectedText")
@@ -165,4 +165,4 @@ function Dropdown:render()
end
end
return Dropdown
return DropDown

View File

@@ -2,7 +2,7 @@ local elementManager = require("elementManager")
local Container = elementManager.getElement("Container")
---@configDescription A flexbox container that arranges its children in a flexible layout.
--- This is the Flexbox class. It is a container that arranges its children in a flexible layout.
--- This is the FlexBox class. It is a container that arranges its children in a flexible layout.
--- @usage local flex = main:addFlexbox({background=colors.black, width=30, height=10})
--- @usage flex:addButton():setFlexGrow(1)
--- @usage flex:addButton():setFlexGrow(1)
@@ -12,16 +12,16 @@ local Container = elementManager.getElement("Container")
--- @usage flex:addButton():setFlexGrow(1) -- The flex-grow property defines the ability for a flex item to grow if necessary.
--- @usage flex:addButton():setFlexShrink(1) -- The flex-shrink property defines the ability for a flex item to shrink if necessary.
--- @usage flex:addButton():setFlexBasis(1) -- The flex-basis property defines the default size of an element before the remaining space is distributed.
---@class Flexbox : Container
local Flexbox = setmetatable({}, Container)
Flexbox.__index = Flexbox
---@class FlexBox : Container
local FlexBox = setmetatable({}, Container)
FlexBox.__index = FlexBox
---@property flexDirection string "row" The direction of the flexbox layout "row" or "column"
Flexbox.defineProperty(Flexbox, "flexDirection", {default = "row", type = "string"})
FlexBox.defineProperty(FlexBox, "flexDirection", {default = "row", type = "string"})
---@property flexSpacing number 1 The spacing between flex items
Flexbox.defineProperty(Flexbox, "flexSpacing", {default = 1, type = "number"})
FlexBox.defineProperty(FlexBox, "flexSpacing", {default = 1, type = "number"})
---@property flexJustifyContent string "flex-start" The alignment of flex items along the main axis
Flexbox.defineProperty(Flexbox, "flexJustifyContent", {
FlexBox.defineProperty(FlexBox, "flexJustifyContent", {
default = "flex-start",
type = "string",
setter = function(self, value)
@@ -32,7 +32,7 @@ Flexbox.defineProperty(Flexbox, "flexJustifyContent", {
end
})
---@property flexAlignItems string "flex-start" The alignment of flex items along the cross axis
Flexbox.defineProperty(Flexbox, "flexAlignItems", {
FlexBox.defineProperty(FlexBox, "flexAlignItems", {
default = "flex-start",
type = "string",
setter = function(self, value)
@@ -43,11 +43,11 @@ Flexbox.defineProperty(Flexbox, "flexAlignItems", {
end
})
---@property flexCrossPadding number 0 The padding on both sides of the cross axis
Flexbox.defineProperty(Flexbox, "flexCrossPadding", {default = 0, type = "number"})
FlexBox.defineProperty(FlexBox, "flexCrossPadding", {default = 0, type = "number"})
---@property flexWrap boolean false Whether to wrap flex items onto multiple lines
---@property flexUpdateLayout boolean false Whether to update the layout of the flexbox
Flexbox.defineProperty(Flexbox, "flexWrap", {default = false, type = "boolean"})
Flexbox.defineProperty(Flexbox, "flexUpdateLayout", {default = false, type = "boolean"})
FlexBox.defineProperty(FlexBox, "flexWrap", {default = false, type = "boolean"})
FlexBox.defineProperty(FlexBox, "flexUpdateLayout", {default = false, type = "boolean"})
local lineBreakElement = {
getHeight = function(self) return 0 end,
@@ -715,12 +715,12 @@ local function updateLayout(self, direction, spacing, justifyContent, wrap)
self.set("flexUpdateLayout", false)
end
--- @shortDescription Creates a new Flexbox instance
--- @return Flexbox object The newly created Flexbox instance
--- @shortDescription Creates a new FlexBox instance
--- @return FlexBox object The newly created FlexBox instance
--- @private
function Flexbox.new()
local self = setmetatable({}, Flexbox):__init()
self.class = Flexbox
function FlexBox.new()
local self = setmetatable({}, FlexBox):__init()
self.class = FlexBox
self.set("width", 12)
self.set("height", 6)
self.set("background", colors.blue)
@@ -741,22 +741,22 @@ function Flexbox.new()
return self
end
--- @shortDescription Initializes the Flexbox instance
--- @shortDescription Initializes the FlexBox instance
--- @param props table The properties to initialize the element with
--- @param basalt table The basalt instance
--- @return Flexbox self The initialized instance
--- @return FlexBox self The initialized instance
--- @protected
function Flexbox:init(props, basalt)
function FlexBox:init(props, basalt)
Container.init(self, props, basalt)
self.set("type", "Flexbox")
self.set("type", "FlexBox")
return self
end
--- Adds a child element to the flexbox
--- @shortDescription Adds a child element to the flexbox
--- @param element Element The child element to add
--- @return Flexbox self The flexbox instance
function Flexbox:addChild(element)
--- @return FlexBox self The flexbox instance
function FlexBox:addChild(element)
Container.addChild(self, element)
if(element~=lineBreakElement)then
@@ -789,9 +789,9 @@ end
--- @shortDescription Removes a child element from the flexbox
--- @param element Element The child element to remove
--- @return Flexbox self The flexbox instance
--- @return FlexBox self The flexbox instance
--- @protected
function Flexbox:removeChild(element)
function FlexBox:removeChild(element)
Container.removeChild(self, element)
if(element~=lineBreakElement)then
@@ -812,20 +812,20 @@ end
--- Adds a new line break to the flexbox
--- @shortDescription Adds a new line break to the flexbox.
---@param self Flexbox The element itself
---@return Flexbox
function Flexbox:addLineBreak()
---@param self FlexBox The element itself
---@return FlexBox
function FlexBox:addLineBreak()
self:addChild(lineBreakElement)
return self
end
--- @shortDescription Renders the flexbox and its children
--- @protected
function Flexbox:render()
function FlexBox:render()
if(self.get("flexUpdateLayout"))then
updateLayout(self, self.get("flexDirection"), self.get("flexSpacing"), self.get("flexJustifyContent"), self.get("flexWrap"))
end
Container.render(self)
end
return Flexbox
return FlexBox