diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 349dc3b..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,64 +0,0 @@ -# Sample workflow for building and deploying a VitePress site to GitHub Pages -# -name: Deploy VitePress site to Pages - -on: - # Runs on pushes targeting the `main` branch. Change this to `master` if you're - # using the `master` branch as the default branch. - push: - branches: [gh-pages] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: pages - cancel-in-progress: false - -jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Not needed if lastUpdated is not enabled - # - uses: pnpm/action-setup@v3 # Uncomment this if you're using pnpm - # - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm # or pnpm / yarn - - name: Setup Pages - uses: actions/configure-pages@v4 - - name: Install dependencies - run: npm ci # or pnpm install / yarn install / bun install - - name: Build with VitePress - run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: docs/.vitepress/dist - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - needs: build - runs-on: ubuntu-latest - name: Deploy - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 diff --git a/docs/content/BaseElement.md b/docs/content/BaseElement.md new file mode 100644 index 0000000..177900f --- /dev/null +++ b/docs/content/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/docs/content/BaseFrame.md b/docs/content/BaseFrame.md new file mode 100644 index 0000000..4b3cbb2 --- /dev/null +++ b/docs/content/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/docs/content/Button.md b/docs/content/Button.md new file mode 100644 index 0000000..5b436b0 --- /dev/null +++ b/docs/content/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/docs/content/Container.md b/docs/content/Container.md new file mode 100644 index 0000000..f172768 --- /dev/null +++ b/docs/content/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/docs/content/Frame.md b/docs/content/Frame.md new file mode 100644 index 0000000..cdbe682 --- /dev/null +++ b/docs/content/Frame.md @@ -0,0 +1,3 @@ +## Frame.new() +@diagnostic disable-next-line: duplicate-set-field + diff --git a/docs/content/VisualElement.md b/docs/content/VisualElement.md new file mode 100644 index 0000000..c4a96cd --- /dev/null +++ b/docs/content/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/docs/content/colorHex.md b/docs/content/colorHex.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/content/elementManager.md b/docs/content/elementManager.md new file mode 100644 index 0000000..8a96789 --- /dev/null +++ b/docs/content/elementManager.md @@ -0,0 +1,14 @@ +## ElementManager.extendMethod() + +## ElementManager.generateId() + +## ElementManager.getElement() + +## ElementManager.getElementList() + +## ElementManager.loadElement() + +## ElementManager.loadPlugin() + +## ElementManager.registerPlugin() + diff --git a/docs/content/errorManager.md b/docs/content/errorManager.md new file mode 100644 index 0000000..255da8e --- /dev/null +++ b/docs/content/errorManager.md @@ -0,0 +1,2 @@ +## errorHandler.error() + diff --git a/docs/content/expect.md b/docs/content/expect.md new file mode 100644 index 0000000..d5e0c13 --- /dev/null +++ b/docs/content/expect.md @@ -0,0 +1 @@ +Simple type checking without stack traces diff --git a/docs/content/init.md b/docs/content/init.md new file mode 100644 index 0000000..bc51543 --- /dev/null +++ b/docs/content/init.md @@ -0,0 +1 @@ +Use xpcall with error handler diff --git a/docs/content/log.md b/docs/content/log.md new file mode 100644 index 0000000..bb00a61 --- /dev/null +++ b/docs/content/log.md @@ -0,0 +1,7 @@ +Log levels +## Log.error() + +## Log.setEnabled() + +## Log.setLogToFile() + diff --git a/docs/content/main.md b/docs/content/main.md new file mode 100644 index 0000000..284e43b --- /dev/null +++ b/docs/content/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/docs/content/propertySystem.md b/docs/content/propertySystem.md new file mode 100644 index 0000000..8b0400b --- /dev/null +++ b/docs/content/propertySystem.md @@ -0,0 +1,8 @@ +## PropertySystem.defineProperty() + +## PropertySystem:__init() + +## PropertySystem:_updateProperty() + +## PropertySystem:observe() + diff --git a/docs/content/render.md b/docs/content/render.md new file mode 100644 index 0000000..8a57035 --- /dev/null +++ b/docs/content/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/docs/content/utils.md b/docs/content/utils.md new file mode 100644 index 0000000..ebfe343 --- /dev/null +++ b/docs/content/utils.md @@ -0,0 +1,4 @@ +## utils.deepCopy() + +## utils.getCenteredPosition() +