diff --git a/BaseElement.md b/BaseElement.md new file mode 100644 index 0000000..177900f --- /dev/null +++ b/BaseElement.md @@ -0,0 +1,112 @@ +# BaseElement +The base class for all UI elements in Basalt + +## Properties + +|Property|Type|Default|Description| +|---|---|---|---| +|type|string|BaseElement|The type identifier of the element +|eventCallbacks|table|{}|Table containing all registered event callbacks + +## Functions + +|Method|Returns|Description| +|---|---|---| +|[BaseElement.listenTo](#BaseElement.listenTo)|-| +|[BaseElement.new](#BaseElement.new)|table| +|[BaseElement:fireEvent](#BaseElement:fireEvent)|table| +|[BaseElement:init](#BaseElement:init)|table| +|[BaseElement:listenEvent](#BaseElement:listenEvent)|table| +|[BaseElement:registerCallback](#BaseElement:registerCallback)|table| +|[BaseElement:updateRender](#BaseElement:updateRender)|-| + +## BaseElement.listenTo(class, eventName) +Registers an event that this class can listen to + +### Parameters +* `class` `table` The class to add the event to +* `eventName` `string` The name of the event to register + +### Usage + ```lua +BaseElement.listenTo(MyClass, "mouse_click") +``` + +## BaseElement.new(id, basalt) +Creates a new BaseElement instance + +### Parameters +* `id` `string` The unique identifier for this element +* `basalt` `table` The basalt instance + +### Returns +* `table` `The` newly created BaseElement instance + +### Usage + ```lua +local element = BaseElement.new("myId", basalt) +``` + +## BaseElement:fireEvent(event, ...) +Triggers an event and calls all registered callbacks + +### Parameters +* `event` `string` The event to fire +* `...` `any` Additional arguments to pass to the callbacks + +### Returns +* `table` `self` The BaseElement instance + +### Usage + ```lua +element:fireEvent("mouse_click", 1, 2) +``` + +## BaseElement:init(id, basalt) +Initializes the BaseElement instance + +### Parameters +* `id` `string` The unique identifier for this element +* `basalt` `table` The basalt instance + +### Returns +* `table` `self` The initialized instance + +## BaseElement:listenEvent(eventName, enable?) +Enables or disables event listening for a specific event + +### Parameters +* `eventName` `string` The name of the event to listen for +* `enable` *(optional)* `boolean` Whether to enable or disable the event (default: true) + +### Returns +* `table` `self` The BaseElement instance + +### Usage + ```lua +element:listenEvent("mouse_click", true) +``` + +## BaseElement:registerCallback(event, callback) +Registers a callback function for an event + +### Parameters +* `event` `string` The event to register the callback for +* `callback` `function` The callback function to register + +### Returns +* `table` `self` The BaseElement instance + +### Usage + ```lua +element:registerCallback("mouse_click", function(self, ...) end) +``` + +## BaseElement:updateRender() +Requests a render update for this element + +### Usage + ```lua +element:updateRender() +``` + diff --git a/BaseFrame.md b/BaseFrame.md new file mode 100644 index 0000000..4b3cbb2 --- /dev/null +++ b/BaseFrame.md @@ -0,0 +1,10 @@ +## BaseFrame.new() +@diagnostic disable-next-line: duplicate-set-field + +## BaseFrame:multiBlit() + +## BaseFrame:render() +@diagnostic disable-next-line: duplicate-set-field + +## BaseFrame:textFg() + diff --git a/Button.md b/Button.md new file mode 100644 index 0000000..5b436b0 --- /dev/null +++ b/Button.md @@ -0,0 +1,6 @@ +## Button.new() +@diagnostic disable-next-line: duplicate-set-field + +## Button:render() +@diagnostic disable-next-line: duplicate-set-field + diff --git a/Container.md b/Container.md new file mode 100644 index 0000000..f172768 --- /dev/null +++ b/Container.md @@ -0,0 +1,28 @@ +## Container.new() +@diagnostic disable-next-line: duplicate-set-field + +## Container:addChild() + +## Container:handleEvent() + +## Container:multiBlit() + +## Container:registerChildEvent() + +## Container:registerChildrenEvents() + +## Container:removeChild() + +## Container:removeChildrenEvents() + +## Container:render() +@diagnostic disable-next-line: duplicate-set-field + +## Container:sortChildren() + +## Container:sortChildrenEvents() + +## Container:textFg() + +## Container:unregisterChildEvent() + diff --git a/Frame.md b/Frame.md new file mode 100644 index 0000000..cdbe682 --- /dev/null +++ b/Frame.md @@ -0,0 +1,3 @@ +## Frame.new() +@diagnostic disable-next-line: duplicate-set-field + diff --git a/VisualElement.md b/VisualElement.md new file mode 100644 index 0000000..c4a96cd --- /dev/null +++ b/VisualElement.md @@ -0,0 +1,37 @@ +## VisualElement.new() +@diagnostic disable-next-line: duplicate-set-field + +## VisualElement:getAbsolutePosition(x?, y?) +Returns the absolute position of the element or the given coordinates. + +### Parameters +* `x` *(optional)* `number` -- x position +* `y` *(optional)* `number` -- y position + +## VisualElement:getRelativePosition(x?, y?) +Returns the relative position of the element or the given coordinates. + +### Parameters +* `x` *(optional)* `number` -- x position +* `y` *(optional)* `number` -- y position + +### Returns +* `nil` `nil` nil + +## VisualElement:handleEvent() + +## VisualElement:isInBounds() + +## VisualElement:mouse_click() + +## VisualElement:mouse_release() + +## VisualElement:mouse_up() + +## VisualElement:multiBlit() + +## VisualElement:render() +@diagnostic disable-next-line: duplicate-set-field + +## VisualElement:textFg() + diff --git a/colorHex.md b/colorHex.md new file mode 100644 index 0000000..e69de29 diff --git a/elementManager.md b/elementManager.md new file mode 100644 index 0000000..8a96789 --- /dev/null +++ b/elementManager.md @@ -0,0 +1,14 @@ +## ElementManager.extendMethod() + +## ElementManager.generateId() + +## ElementManager.getElement() + +## ElementManager.getElementList() + +## ElementManager.loadElement() + +## ElementManager.loadPlugin() + +## ElementManager.registerPlugin() + diff --git a/errorManager.md b/errorManager.md new file mode 100644 index 0000000..255da8e --- /dev/null +++ b/errorManager.md @@ -0,0 +1,2 @@ +## errorHandler.error() + diff --git a/expect.md b/expect.md new file mode 100644 index 0000000..d5e0c13 --- /dev/null +++ b/expect.md @@ -0,0 +1 @@ +Simple type checking without stack traces diff --git a/index.html b/index.html deleted file mode 100644 index 78268a6..0000000 --- a/index.html +++ /dev/null @@ -1,414 +0,0 @@ - - - - - Basalt Documentation - - - - -
- -
- -
-
-
- - -
- - - - - - -
- -

Module basalt

-

Basalt UI Framework main module.

-

This is the main entry point for the Basalt UI Framework. - It provides functions for creating and managing UI elements and handling events.

-

Usage:

-
    -
    local basalt = require("basalt")
    -local mainFrame = basalt.createFrame()
    -mainFrame:show()
    -basalt.run()
    -
    -
- - -

Class Basalt

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
basalt:create (type, id)Creates and returns a new UI element of the specified type
basalt:createFrame ()Creates and returns a new frame
basalt:getElementManager ()Returns the element manager instance
basalt:getMainFrame ()Gets or creates the main frame
basalt:setActiveFrame (frame)Sets the active frame
basalt:scheduleUpdate (func)Schedules a function to be updated
basalt:removeSchedule (id)Removes a scheduled update
basalt.updateEvent (event, ...)Internal event handler
basalt.renderFrames ()Internal render function
basalt:update ()Updates all scheduled functions
basalt:stop ()Stops the Basalt runtime
basalt:run (isActive)Starts the Basalt runtime
- -
-
- - -

Class Basalt

- -
- The main Basalt instance - Contains all core functionality and management functions -
-
-
- - basalt:create (type, id) -
-
- Creates and returns a new UI element of the specified type - - -

Parameters:

-
    -
  • type - string The type of element to create (e.g. "Button", "Label", "BaseFrame") -
  • -
  • id - ? string Optional unique identifier for the element -
  • -
- -

Returns:

-
    - - table element The created element instance -
- - - -

Usage:

-
    -
    local button = basalt.create("Button")
    -
- -
-
- - basalt:createFrame () -
-
- Creates and returns a new frame - - - -

Returns:

-
    - - table BaseFrame The created frame instance -
- - - -

Usage:

-
    -
    local mainFrame = basalt.createFrame()
    -
- -
-
- - basalt:getElementManager () -
-
- Returns the element manager instance - - - -

Returns:

-
    - - table ElementManager The element manager -
- - - -

Usage:

-
    -
    local manager = basalt.getElementManager()
    -
- -
-
- - basalt:getMainFrame () -
-
- Gets or creates the main frame - - - -

Returns:

-
    - - BaseFrame table The main frame instance -
- - - -

Usage:

-
    -
    local frame = basalt.getMainFrame()
    -
- -
-
- - basalt:setActiveFrame (frame) -
-
- Sets the active frame - - -

Parameters:

-
    -
  • frame - table The frame to set as active -
  • -
- - - - -

Usage:

-
    -
    basalt.setActiveFrame(myFrame)
    -
- -
-
- - basalt:scheduleUpdate (func) -
-
- Schedules a function to be updated - - -

Parameters:

-
    -
  • func - function The function to schedule -
  • -
- -

Returns:

-
    - - number Id The schedule ID -
- - - -

Usage:

-
    -
    local id = basalt.scheduleUpdate(myFunction)
    -
- -
-
- - basalt:removeSchedule (id) -
-
- Removes a scheduled update - - -

Parameters:

-
    -
  • id - number The schedule ID to remove -
  • -
- - - - -

Usage:

-
    -
    basalt.removeSchedule(scheduleId)
    -
- -
-
- - basalt.updateEvent (event, ...) -
-
- Internal event handler - - -

Parameters:

-
    -
  • event - - - -
  • -
  • ... - - - -
  • -
- - - - - -
-
- - basalt.renderFrames () -
-
- Internal render function - - - - - - - -
-
- - basalt:update () -
-
- Updates all scheduled functions - - - - - - -

Usage:

-
    -
    basalt.update()
    -
- -
-
- - basalt:stop () -
-
- Stops the Basalt runtime - - - - - - -

Usage:

-
    -
    basalt.stop()
    -
- -
-
- - basalt:run (isActive) -
-
- Starts the Basalt runtime - - -

Parameters:

-
    -
  • isActive - boolean Whether to start active (default: true) -
  • -
- - - - -

Usage:

-
    -
  • basalt.run()
  • -
  • basalt.run(false)
  • -
- -
-
- - -
-
-
-generated by LDoc 1.5.0 -Last updated 2025-02-09 18:44:59 -
-
- - diff --git a/init.md b/init.md new file mode 100644 index 0000000..bc51543 --- /dev/null +++ b/init.md @@ -0,0 +1 @@ +Use xpcall with error handler diff --git a/ldoc.css b/ldoc.css deleted file mode 100644 index 3fc7a39..0000000 --- a/ldoc.css +++ /dev/null @@ -1,305 +0,0 @@ -/* BEGIN RESET - -Copyright (c) 2010, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.8.2r1 -*/ -html { - color: #dfdfdf; - background: #1b1b1b; -} -body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { - margin: 0; - padding: 0; -} -table { - border-collapse: collapse; - border-spacing: 0; -} -fieldset,img { - border: 0; -} -address,caption,cite,code,dfn,em,strong,th,var,optgroup { - font-style: inherit; - font-weight: inherit; -} -del,ins { - text-decoration: none; -} -li { - list-style: bullet; - margin-left: 20px; -} -caption,th { - text-align: left; -} -h1,h2,h3,h4,h5,h6 { - font-size: 100%; - font-weight: bold; -} -q:before,q:after { - content: ''; -} -abbr,acronym { - border: 0; - font-variant: normal; -} -sup { - vertical-align: baseline; -} -sub { - vertical-align: baseline; -} -legend { - color: #000; -} -input,button,textarea,select,optgroup,option { - font-family: inherit; - font-size: inherit; - font-style: inherit; - font-weight: inherit; -} -input,button,textarea,select {*font-size:100%;} -/* END RESET */ - -body { - margin-left: 1em; - margin-right: 1em; - font-family: arial, helvetica, geneva, sans-serif; - background-color: #1a1a1a; - color: #e0e0e0; -} - -code, tt { - font-family: monospace; - color: #88ccff; -} - -body, p, td, th { font-size: .95em; line-height: 1.2em;} - -p, ul { margin: 10px 0 0 10px;} - -strong { font-weight: bold;} - -em { font-style: italic;} - -h1 { - font-size: 1.5em; - margin: 0 0 20px 0; - color: #ffffff; -} -h2, h3, h4 { margin: 15px 0 10px 0; color: #ffffff; } -h2 { font-size: 1.25em; } -h3 { font-size: 1.15em; } -h4 { font-size: 1.06em; } - -a:link { font-weight: bold; color: #66b3ff; text-decoration: none; } -a:visited { font-weight: bold; color: #b366ff; text-decoration: none; } -a:link:hover { text-decoration: underline; } - -hr { - color: #c9c9c9; - background: #444444; - height: 1px; -} - -blockquote { margin-left: 3em; } - -ul { list-style-type: disc; } - -p.name { - font-family: "Andale Mono", monospace; - padding-top: 1em; -} - -pre.example { - background-color: #2d2d2d; - border: 1px solid #444444; - padding: 10px; - margin: 10px 0 10px 0; - font-family: "Andale Mono", monospace; - font-size: .85em; - color: #e0e0e0; -} - -pre { - background-color: #2d2d2d; - border: 1px solid #444444; - padding: 10px; - margin: 10px 0 10px 0; - font-family: "Andale Mono", monospace; - color: #e0e0e0; -} - - -table.index { border: 1px #00007f; } -table.index td { text-align: left; vertical-align: top; } - -#container { - margin-left: 1em; - margin-right: 1em; - background-color: #242424; -} - -#product { - text-align: center; - border-bottom: 1px solid #cccccc; - background-color: #3a3a3a; -} - -#product big { - font-size: 2em; -} - -#main { - background-color: #131313; - border-left: 2px solid #cccccc; -} - -#navigation { - float: left; - width: 14em; - vertical-align: top; - background-color: #2d2d2d; - overflow: visible; -} - -#navigation h2 { - background-color: #333333; - font-size: 1.1em; - color: #ffffff; - text-align: left; - padding: 0.2em; - border-top: 1px solid #444444; - border-bottom: 1px solid #444444; -} - -#navigation ul -{ - font-size: 1em; - list-style-type: none; - margin: 1px 1px 10px 1px; -} - -#navigation li { - text-indent: -1em; - display: block; - margin: 3px 0px 0px 22px; -} - -#navigation li li a { - margin: 0px 3px 0px -1em; -} - -#content { - margin-left: 14em; - width: 40em; - padding: 1em; - border-left: 2px solid #444444; - border-right: 2px solid #444444; - background-color: #242424; -} - -#about { - clear: both; - padding: 5px; - border-top: 2px solid #cccccc; - background-color: #202020; -} - -@media print { - body { - font: 12pt "Times New Roman", "TimeNR", Times, serif; - } - a { font-weight: bold; color: #004080; text-decoration: underline; } - - #main { - background-color: #1d1a1a; - border-left: 0px; - } - - #container { - margin-left: 2%; - margin-right: 2%; - background-color: #1b1a1a; - } - - #content { - padding: 1em; - background-color: #1d1a1a; - } - - #navigation { - display: none; - } - pre.example { - font-family: "Andale Mono", monospace; - font-size: 10pt; - page-break-inside: avoid; - } -} - -table.module_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #444444; -} -table.module_list td.name { background-color: #333333; } -table.module_list td.summary { width: 100%; } - -table.file_list { - border-width: 1px; - border-style: solid; - border-color: #444444; - border-collapse: collapse; -} -table.file_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #444444; -} - -table.file_list td.name { background-color: #333333; } - -table.file_list td.summary { width: 100%; } - -table.function_list { - border-width: 1px; - border-style: solid; - border-color: #444444; - border-collapse: collapse; -} -table.function_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #444444; -} - -table.function_list td.name { background-color: #333333; } - -table.function_list td.summary { width: 100%; } - -table.table_list { - border-width: 1px; - border-style: solid; - border-color: #444444; - border-collapse: collapse; -} -table.table_list td { - border-width: 1px; - padding: 3px; - border-style: solid; - border-color: #444444; -} - -table.table_list td.name { background-color: #333333; } - -table.table_list td.summary { width: 100%; } - -dl.table dt, dl.function dt {border-top: 1px solid #444444; padding-top: 1em;} -dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;} -dl.table h3, dl.function h3 {font-size: .95em;} \ No newline at end of file diff --git a/log.md b/log.md new file mode 100644 index 0000000..bb00a61 --- /dev/null +++ b/log.md @@ -0,0 +1,7 @@ +Log levels +## Log.error() + +## Log.setEnabled() + +## Log.setLogToFile() + diff --git a/main.md b/main.md new file mode 100644 index 0000000..d945414 --- /dev/null +++ b/main.md @@ -0,0 +1,139 @@ +# Basalt +This is the UI Manager and the starting point for your project. The following functions allow you to influence the default behavior of Basalt. + +Before you can access Basalt, you need to add the following code on top of your file: + +### Usage + ```lua +local basalt = require("basalt") +``` + +What this code does is it loads basalt into the project, and you can access it by using the variable defined as "basalt". + +## Functions + +|Method|Returns|Description| +|---|---|---| +|[basalt.create](#basalt.create)|table|Creates a new UI element +|[basalt.createFrame](#basalt.createFrame)|table| +|[basalt.getElementManager](#basalt.getElementManager)|table| +|[basalt.getMainFrame](#basalt.getMainFrame)|BaseFrame| +|[basalt.removeSchedule](#basalt.removeSchedule)|-| +|[basalt.run](#basalt.run)|-| +|[basalt.scheduleUpdate](#basalt.scheduleUpdate)|number| +|[basalt.setActiveFrame](#basalt.setActiveFrame)|-| +|[basalt.stop](#basalt.stop)|-| +|[basalt.update](#basalt.update)|-| + +## basalt.create(type, id?) +Creates and returns a new UI element of the specified type + +### Parameters +* `type` `string` The type of element to create (e.g. "Button", "Label", "BaseFrame") +* `id` *(optional)* `string` Optional unique identifier for the element + +### Returns +* `table` `element` The created element instance + +### Usage + ```lua +local button = basalt.create("Button") +``` + +## basalt.createFrame() +Creates and returns a new frame + +### Returns +* `table` `BaseFrame` The created frame instance + +### Usage + ```lua +local mainFrame = basalt.createFrame() +``` + +## basalt.getElementManager() +Returns the element manager instance + +### Returns +* `table` `ElementManager` The element manager + +### Usage + ```lua +local manager = basalt.getElementManager() +``` + +## basalt.getMainFrame() +Gets or creates the main frame + +### Returns +* `BaseFrame` `table` The main frame instance + +### Usage + ```lua +local frame = basalt.getMainFrame() +``` + +## basalt.removeSchedule(id) +Removes a scheduled update + +### Parameters +* `id` `number` The schedule ID to remove + +### Usage + ```lua +basalt.removeSchedule(scheduleId) +``` + +## basalt.run(isActive) +Starts the Basalt runtime + +### Parameters +* `isActive` `boolean` Whether to start active (default: true) + +### Usage + ```lua +basalt.run() +basalt.run(false) +``` + +## basalt.scheduleUpdate(func) +Schedules a function to be updated + +### Parameters +* `func` `function` The function to schedule + +### Returns +* `number` `Id` The schedule ID + +### Usage + ```lua +local id = basalt.scheduleUpdate(myFunction) +``` + +## basalt.setActiveFrame(frame) +Sets the active frame + +### Parameters +* `frame` `table` The frame to set as active + +### Usage + ```lua +basalt.setActiveFrame(myFrame) +``` + +## basalt.stop() +Stops the Basalt runtime + +### Usage + ```lua +basalt.stop() +``` + +## basalt.update() +Updates all scheduled functions + +### Usage + ```lua +basalt.update() +``` + diff --git a/propertySystem.md b/propertySystem.md new file mode 100644 index 0000000..8b0400b --- /dev/null +++ b/propertySystem.md @@ -0,0 +1,8 @@ +## PropertySystem.defineProperty() + +## PropertySystem:__init() + +## PropertySystem:_updateProperty() + +## PropertySystem:observe() + diff --git a/render.md b/render.md new file mode 100644 index 0000000..8a57035 --- /dev/null +++ b/render.md @@ -0,0 +1,22 @@ +## Render.new() + +## Render:bg() + +## Render:blit() + +## Render:clear() + +## Render:clearArea() + +## Render:fg() + +## Render:getSize() + +## Render:multiBlit() + +## Render:render() + +## Render:text() + +## Render:textFg() + diff --git a/utils.md b/utils.md new file mode 100644 index 0000000..ebfe343 --- /dev/null +++ b/utils.md @@ -0,0 +1,4 @@ +## utils.deepCopy() + +## utils.getCenteredPosition() +