Skip to content

Commit 264b1b9

Browse files
committed
Class rename
1 parent dd6a120 commit 264b1b9

File tree

5 files changed

+82
-82
lines changed

5 files changed

+82
-82
lines changed

release/basalt.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ self:textFg(1,y,
13781378
bd..string.rep(" ",self.get("width")-#bd),self.get("foreground"))else
13791379
self:textFg(1,y,string.rep(" ",self.get("width")),self.get("foreground"),self.get("background"))end end end;return ba end
13801380
project["elements/ComboBox.lua"] = function(...) local _a=require("elements/VisualElement")
1381-
local aa=require("elements/Dropdown")local ba=require("libraries/colorHex")
1381+
local aa=require("src.elements.DropDown")local ba=require("libraries/colorHex")
13821382
local ca=setmetatable({},aa)ca.__index=ca
13831383
ca.defineProperty(ca,"editable",{default=true,type="boolean",canTriggerRender=true})
13841384
ca.defineProperty(ca,"text",{default="",type="string",canTriggerRender=true})

src/elements/Checkbox.lua

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
local VisualElement = require("elements/VisualElement")
22
---@cofnigDescription This is a checkbox. It is a visual element that can be checked.
33

4-
--- The Checkbox is a visual element that can be checked.
5-
---@class Checkbox : VisualElement
6-
local Checkbox = setmetatable({}, VisualElement)
7-
Checkbox.__index = Checkbox
4+
--- The CheckBox is a visual element that can be checked.
5+
---@class CheckBox : VisualElement
6+
local CheckBox = setmetatable({}, VisualElement)
7+
CheckBox.__index = CheckBox
88

99
---@property checked boolean Whether checkbox is checked
10-
Checkbox.defineProperty(Checkbox, "checked", {default = false, type = "boolean", canTriggerRender = true})
10+
CheckBox.defineProperty(CheckBox, "checked", {default = false, type = "boolean", canTriggerRender = true})
1111
---@property text string empty Text to display
12-
Checkbox.defineProperty(Checkbox, "text", {default = " ", type = "string", canTriggerRender = true, setter=function(self, value)
12+
CheckBox.defineProperty(CheckBox, "text", {default = " ", type = "string", canTriggerRender = true, setter=function(self, value)
1313
local checkedText = self.get("checkedText")
1414
local width = math.max(#value, #checkedText)
1515
if(self.get("autoSize"))then
@@ -18,7 +18,7 @@ Checkbox.defineProperty(Checkbox, "text", {default = " ", type = "string", canTr
1818
return value
1919
end})
2020
---@property checkedText string Text when checked
21-
Checkbox.defineProperty(Checkbox, "checkedText", {default = "x", type = "string", canTriggerRender = true, setter=function(self, value)
21+
CheckBox.defineProperty(CheckBox, "checkedText", {default = "x", type = "string", canTriggerRender = true, setter=function(self, value)
2222
local text = self.get("text")
2323
local width = math.max(#value, #text)
2424
if(self.get("autoSize"))then
@@ -27,28 +27,28 @@ Checkbox.defineProperty(Checkbox, "checkedText", {default = "x", type = "string"
2727
return value
2828
end})
2929
---@property autoSize boolean true Whether to automatically size the checkbox
30-
Checkbox.defineProperty(Checkbox, "autoSize", {default = true, type = "boolean"})
30+
CheckBox.defineProperty(CheckBox, "autoSize", {default = true, type = "boolean"})
3131

32-
Checkbox.defineEvent(Checkbox, "mouse_click")
33-
Checkbox.defineEvent(Checkbox, "mouse_up")
32+
CheckBox.defineEvent(CheckBox, "mouse_click")
33+
CheckBox.defineEvent(CheckBox, "mouse_up")
3434

35-
--- @shortDescription Creates a new Checkbox instance
36-
--- @return Checkbox self The created instance
35+
--- @shortDescription Creates a new CheckBox instance
36+
--- @return CheckBox self The created instance
3737
--- @protected
38-
function Checkbox.new()
39-
local self = setmetatable({}, Checkbox):__init()
40-
self.class = Checkbox
38+
function CheckBox.new()
39+
local self = setmetatable({}, CheckBox):__init()
40+
self.class = CheckBox
4141
self.set("backgroundEnabled", false)
4242
return self
4343
end
4444

45-
--- @shortDescription Initializes the Checkbox instance
45+
--- @shortDescription Initializes the CheckBox instance
4646
--- @param props table The properties to initialize the element with
4747
--- @param basalt table The basalt instance
4848
--- @protected
49-
function Checkbox:init(props, basalt)
49+
function CheckBox:init(props, basalt)
5050
VisualElement.init(self, props, basalt)
51-
self.set("type", "Checkbox")
51+
self.set("type", "CheckBox")
5252
end
5353

5454
--- @shortDescription Handles mouse click events
@@ -57,17 +57,17 @@ end
5757
--- @param y number The y position of the click
5858
--- @return boolean Clicked Whether the event was handled
5959
--- @protected
60-
function Checkbox:mouse_click(button, x, y)
60+
function CheckBox:mouse_click(button, x, y)
6161
if VisualElement.mouse_click(self, button, x, y) then
6262
self.set("checked", not self.get("checked"))
6363
return true
6464
end
6565
return false
6666
end
6767

68-
--- @shortDescription Renders the Checkbox
68+
--- @shortDescription Renders the CheckBox
6969
--- @protected
70-
function Checkbox:render()
70+
function CheckBox:render()
7171
VisualElement.render(self)
7272

7373
local checked = self.get("checked")
@@ -78,4 +78,4 @@ function Checkbox:render()
7878
self:textFg(1, 1, text, self.get("foreground"))
7979
end
8080

81-
return Checkbox
81+
return CheckBox

src/elements/ComboBox.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local VisualElement = require("elements/VisualElement")
2-
local Dropdown = require("elements/Dropdown")
2+
local Dropdown = require("src.elements.DropDown")
33
local tHex = require("libraries/colorHex")
44

55
---@configDescription A ComboBox that combines dropdown selection with editable text input

src/elements/Dropdown.lua

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,50 @@ local VisualElement = require("elements/VisualElement")
22
local List = require("elements/List")
33
local tHex = require("libraries/colorHex")
44

5-
---@configDescription A dropdown menu that shows a list of selectable items
5+
---@configDescription A DropDown menu that shows a list of selectable items
66
---@configDefault false
77

8-
--- This is the dropdown class. It is a visual element that can show a list of selectable items in a dropdown menu.
9-
--- @usage local dropdown = main:addDropdown()
10-
--- @usage dropdown:setItems({
8+
--- This is the DropDown class. It is a visual element that can show a list of selectable items in a DropDown menu.
9+
--- @usage local DropDown = main:addDropdown()
10+
--- @usage DropDown:setItems({
1111
--- @usage {text = "Item 1", callback = function() basalt.LOGGER.debug("Item 1 selected") end},
1212
--- @usage {text = "Item 2", callback = function() basalt.LOGGER.debug("Item 2 selected") end},
1313
--- @usage {text = "Item 3", callback = function() basalt.LOGGER.debug("Item 3 selected") end},
1414
--- @usage })
15-
---@class Dropdown : List
16-
local Dropdown = setmetatable({}, List)
17-
Dropdown.__index = Dropdown
18-
19-
---@property isOpen boolean false Whether the dropdown menu is currently open
20-
Dropdown.defineProperty(Dropdown, "isOpen", {default = false, type = "boolean", canTriggerRender = true})
21-
---@property dropdownHeight number 5 Maximum height of the dropdown menu when open
22-
Dropdown.defineProperty(Dropdown, "dropdownHeight", {default = 5, type = "number"})
15+
---@class DropDown : List
16+
local DropDown = setmetatable({}, List)
17+
DropDown.__index = DropDown
18+
19+
---@property isOpen boolean false Whether the DropDown menu is currently open
20+
DropDown.defineProperty(DropDown, "isOpen", {default = false, type = "boolean", canTriggerRender = true})
21+
---@property dropdownHeight number 5 Maximum height of the DropDown menu when open
22+
DropDown.defineProperty(DropDown, "dropdownHeight", {default = 5, type = "number"})
2323
---@property selectedText string "" The text to show when no item is selected
24-
Dropdown.defineProperty(Dropdown, "selectedText", {default = "", type = "string"})
25-
---@property dropSymbol string "\31" The symbol to show for dropdown indication
26-
Dropdown.defineProperty(Dropdown, "dropSymbol", {default = "\31", type = "string"})
24+
DropDown.defineProperty(DropDown, "selectedText", {default = "", type = "string"})
25+
---@property dropSymbol string "\31" The symbol to show for DropDown indication
26+
DropDown.defineProperty(DropDown, "dropSymbol", {default = "\31", type = "string"})
2727

28-
--- Creates a new Dropdown instance
29-
--- @shortDescription Creates a new Dropdown instance
30-
--- @return Dropdown self The newly created Dropdown instance
28+
--- Creates a new DropDown instance
29+
--- @shortDescription Creates a new DropDown instance
30+
--- @return DropDown self The newly created DropDown instance
3131
--- @private
32-
function Dropdown.new()
33-
local self = setmetatable({}, Dropdown):__init()
34-
self.class = Dropdown
32+
function DropDown.new()
33+
local self = setmetatable({}, DropDown):__init()
34+
self.class = DropDown
3535
self.set("width", 16)
3636
self.set("height", 1)
3737
self.set("z", 8)
3838
return self
3939
end
4040

41-
--- @shortDescription Initializes the Dropdown instance
41+
--- @shortDescription Initializes the DropDown instance
4242
--- @param props table The properties to initialize the element with
4343
--- @param basalt table The basalt instance
44-
--- @return Dropdown self The initialized instance
44+
--- @return DropDown self The initialized instance
4545
--- @protected
46-
function Dropdown:init(props, basalt)
46+
function DropDown:init(props, basalt)
4747
List.init(self, props, basalt)
48-
self.set("type", "Dropdown")
48+
self.set("type", "DropDown")
4949
return self
5050
end
5151

@@ -55,7 +55,7 @@ end
5555
--- @param y number The y position of the click
5656
--- @return boolean handled Whether the event was handled
5757
--- @protected
58-
function Dropdown:mouse_click(button, x, y)
58+
function DropDown:mouse_click(button, x, y)
5959
if not VisualElement.mouse_click(self, button, x, y) then return false end
6060

6161
local relX, relY = self:getRelativePosition(x, y)
@@ -103,9 +103,9 @@ function Dropdown:mouse_click(button, x, y)
103103
return false
104104
end
105105

106-
--- @shortDescription Renders the Dropdown
106+
--- @shortDescription Renders the DropDown
107107
--- @protected
108-
function Dropdown:render()
108+
function DropDown:render()
109109
VisualElement.render(self)
110110

111111
local text = self.get("selectedText")
@@ -165,4 +165,4 @@ function Dropdown:render()
165165
end
166166
end
167167

168-
return Dropdown
168+
return DropDown

src/elements/Flexbox.lua

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local elementManager = require("elementManager")
22
local Container = elementManager.getElement("Container")
33
---@configDescription A flexbox container that arranges its children in a flexible layout.
44

5-
--- This is the Flexbox class. It is a container that arranges its children in a flexible layout.
5+
--- This is the FlexBox class. It is a container that arranges its children in a flexible layout.
66
--- @usage local flex = main:addFlexbox({background=colors.black, width=30, height=10})
77
--- @usage flex:addButton():setFlexGrow(1)
88
--- @usage flex:addButton():setFlexGrow(1)
@@ -12,16 +12,16 @@ local Container = elementManager.getElement("Container")
1212
--- @usage flex:addButton():setFlexGrow(1) -- The flex-grow property defines the ability for a flex item to grow if necessary.
1313
--- @usage flex:addButton():setFlexShrink(1) -- The flex-shrink property defines the ability for a flex item to shrink if necessary.
1414
--- @usage flex:addButton():setFlexBasis(1) -- The flex-basis property defines the default size of an element before the remaining space is distributed.
15-
---@class Flexbox : Container
16-
local Flexbox = setmetatable({}, Container)
17-
Flexbox.__index = Flexbox
15+
---@class FlexBox : Container
16+
local FlexBox = setmetatable({}, Container)
17+
FlexBox.__index = FlexBox
1818

1919
---@property flexDirection string "row" The direction of the flexbox layout "row" or "column"
20-
Flexbox.defineProperty(Flexbox, "flexDirection", {default = "row", type = "string"})
20+
FlexBox.defineProperty(FlexBox, "flexDirection", {default = "row", type = "string"})
2121
---@property flexSpacing number 1 The spacing between flex items
22-
Flexbox.defineProperty(Flexbox, "flexSpacing", {default = 1, type = "number"})
22+
FlexBox.defineProperty(FlexBox, "flexSpacing", {default = 1, type = "number"})
2323
---@property flexJustifyContent string "flex-start" The alignment of flex items along the main axis
24-
Flexbox.defineProperty(Flexbox, "flexJustifyContent", {
24+
FlexBox.defineProperty(FlexBox, "flexJustifyContent", {
2525
default = "flex-start",
2626
type = "string",
2727
setter = function(self, value)
@@ -32,7 +32,7 @@ Flexbox.defineProperty(Flexbox, "flexJustifyContent", {
3232
end
3333
})
3434
---@property flexAlignItems string "flex-start" The alignment of flex items along the cross axis
35-
Flexbox.defineProperty(Flexbox, "flexAlignItems", {
35+
FlexBox.defineProperty(FlexBox, "flexAlignItems", {
3636
default = "flex-start",
3737
type = "string",
3838
setter = function(self, value)
@@ -43,11 +43,11 @@ Flexbox.defineProperty(Flexbox, "flexAlignItems", {
4343
end
4444
})
4545
---@property flexCrossPadding number 0 The padding on both sides of the cross axis
46-
Flexbox.defineProperty(Flexbox, "flexCrossPadding", {default = 0, type = "number"})
46+
FlexBox.defineProperty(FlexBox, "flexCrossPadding", {default = 0, type = "number"})
4747
---@property flexWrap boolean false Whether to wrap flex items onto multiple lines
4848
---@property flexUpdateLayout boolean false Whether to update the layout of the flexbox
49-
Flexbox.defineProperty(Flexbox, "flexWrap", {default = false, type = "boolean"})
50-
Flexbox.defineProperty(Flexbox, "flexUpdateLayout", {default = false, type = "boolean"})
49+
FlexBox.defineProperty(FlexBox, "flexWrap", {default = false, type = "boolean"})
50+
FlexBox.defineProperty(FlexBox, "flexUpdateLayout", {default = false, type = "boolean"})
5151

5252
local lineBreakElement = {
5353
getHeight = function(self) return 0 end,
@@ -715,12 +715,12 @@ local function updateLayout(self, direction, spacing, justifyContent, wrap)
715715
self.set("flexUpdateLayout", false)
716716
end
717717

718-
--- @shortDescription Creates a new Flexbox instance
719-
--- @return Flexbox object The newly created Flexbox instance
718+
--- @shortDescription Creates a new FlexBox instance
719+
--- @return FlexBox object The newly created FlexBox instance
720720
--- @private
721-
function Flexbox.new()
722-
local self = setmetatable({}, Flexbox):__init()
723-
self.class = Flexbox
721+
function FlexBox.new()
722+
local self = setmetatable({}, FlexBox):__init()
723+
self.class = FlexBox
724724
self.set("width", 12)
725725
self.set("height", 6)
726726
self.set("background", colors.blue)
@@ -741,22 +741,22 @@ function Flexbox.new()
741741
return self
742742
end
743743

744-
--- @shortDescription Initializes the Flexbox instance
744+
--- @shortDescription Initializes the FlexBox instance
745745
--- @param props table The properties to initialize the element with
746746
--- @param basalt table The basalt instance
747-
--- @return Flexbox self The initialized instance
747+
--- @return FlexBox self The initialized instance
748748
--- @protected
749-
function Flexbox:init(props, basalt)
749+
function FlexBox:init(props, basalt)
750750
Container.init(self, props, basalt)
751-
self.set("type", "Flexbox")
751+
self.set("type", "FlexBox")
752752
return self
753753
end
754754

755755
--- Adds a child element to the flexbox
756756
--- @shortDescription Adds a child element to the flexbox
757757
--- @param element Element The child element to add
758-
--- @return Flexbox self The flexbox instance
759-
function Flexbox:addChild(element)
758+
--- @return FlexBox self The flexbox instance
759+
function FlexBox:addChild(element)
760760
Container.addChild(self, element)
761761

762762
if(element~=lineBreakElement)then
@@ -789,9 +789,9 @@ end
789789

790790
--- @shortDescription Removes a child element from the flexbox
791791
--- @param element Element The child element to remove
792-
--- @return Flexbox self The flexbox instance
792+
--- @return FlexBox self The flexbox instance
793793
--- @protected
794-
function Flexbox:removeChild(element)
794+
function FlexBox:removeChild(element)
795795
Container.removeChild(self, element)
796796

797797
if(element~=lineBreakElement)then
@@ -812,20 +812,20 @@ end
812812

813813
--- Adds a new line break to the flexbox
814814
--- @shortDescription Adds a new line break to the flexbox.
815-
---@param self Flexbox The element itself
816-
---@return Flexbox
817-
function Flexbox:addLineBreak()
815+
---@param self FlexBox The element itself
816+
---@return FlexBox
817+
function FlexBox:addLineBreak()
818818
self:addChild(lineBreakElement)
819819
return self
820820
end
821821

822822
--- @shortDescription Renders the flexbox and its children
823823
--- @protected
824-
function Flexbox:render()
824+
function FlexBox:render()
825825
if(self.get("flexUpdateLayout"))then
826826
updateLayout(self, self.get("flexDirection"), self.get("flexSpacing"), self.get("flexJustifyContent"), self.get("flexWrap"))
827827
end
828828
Container.render(self)
829829
end
830830

831-
return Flexbox
831+
return FlexBox

0 commit comments

Comments
 (0)