From bf1b008084c796eec55ae3b6433afed882adaf2d Mon Sep 17 00:00:00 2001
From: Robert Jelic <36573031+NoryiE@users.noreply.github.com>
Date: Sun, 9 Oct 2022 14:00:35 +0200
Subject: [PATCH] Docs update
Some more stuff for docs
---
docs/objects/Animation.md | 13 +++++++-
docs/objects/Animation/addMode.md | 30 +++++++++++++++++
docs/objects/Animation/onStart.md | 16 +++++++++
docs/objects/Animation/setMode.md | 36 +++++++++++++++++++++
docs/objects/Basalt.md | 2 ++
docs/objects/Basalt/setMouseDragThrottle.md | 18 +++++++++++
docs/objects/Basalt/setMouseMoveThrottle.md | 20 ++++++++++++
docs/objects/Object.md | 2 ++
docs/objects/Object/onHover.md | 21 ++++++++++++
docs/objects/Object/onLeave.md | 21 ++++++++++++
docs/objects/Program.md | 1 +
docs/objects/Program/setEnviroment.md | 10 ++++++
12 files changed, 189 insertions(+), 1 deletion(-)
create mode 100644 docs/objects/Animation/addMode.md
create mode 100644 docs/objects/Animation/onStart.md
create mode 100644 docs/objects/Animation/setMode.md
create mode 100644 docs/objects/Basalt/setMouseDragThrottle.md
create mode 100644 docs/objects/Basalt/setMouseMoveThrottle.md
create mode 100644 docs/objects/Object/onHover.md
create mode 100644 docs/objects/Object/onLeave.md
create mode 100644 docs/objects/Program/setEnviroment.md
diff --git a/docs/objects/Animation.md b/docs/objects/Animation.md
index ef789f0..cd78716 100644
--- a/docs/objects/Animation.md
+++ b/docs/objects/Animation.md
@@ -1,4 +1,12 @@
-With animations, you can create a beautiful experience for users while interacting with your program.
+With animations, you can create a beautiful experience for users while interacting with your program.
+There are 2 types of animations, predefined animations and custom animations. By using add and wait you can create custom
+animations (calls). Pre-defined methods are for example move, offset, size, changeText,...
+
+:setObject always sets the object on what pre-defined methods should apply on.
+
+When calling a pre-defined animation it will check what is safed as object (:setObject) and will calculate the animation methods based on that which means you won't
+be able to change the object on the fly - you will always have to recreate the animation itself
+
| | |
|---|---|
@@ -6,6 +14,8 @@ With animations, you can create a beautiful experience for users while interacti
|[wait](objects/Animation/wait.md)|Adds a amount to the animation time
|[play](objects/Animation/play.md)|Plays the animation
|[cancel](objects/Animation/cancel.md)|Cancels the animation
+|[addMode](objects/Animation/addMode.md)|Adds custom easings
+|[setMode](objects/Animation/setMode.md)|Changes the current easing-calculation
|[setObject](objects/Animation/setObject.md)|Sets an object on which predefined animations should work on
|[move](objects/Animation/move.md)|Predefined animation: moves the object to a new position
|[offset](objects/Animation/offset.md)|Predefined animation: Changes the offset of that object
@@ -18,4 +28,5 @@ With animations, you can create a beautiful experience for users while interacti
| | |
|---|---|
+|[onStart](objects/Animation/onStart.md)|Gets called as soon as the animation is started
|[onDone](objects/Animation/onDone.md)|Gets called as soon as the animation has finished
diff --git a/docs/objects/Animation/addMode.md b/docs/objects/Animation/addMode.md
new file mode 100644
index 0000000..7241830
--- /dev/null
+++ b/docs/objects/Animation/addMode.md
@@ -0,0 +1,30 @@
+## addMode
+Adds a new easing curve into the available easing list. Checkout the animation object if you want to know how this works.
+
+#### Parameters:
+
+1. `string` - The name of the curve you want to use.
+2. `functon` - The function to call
+
+#### Returns:
+
+1. `animation` Animation in use
+
+#### Usage:
+
+* Creates a new curve
+
+```lua
+local mainFrame = basalt.createFrame()
+local testButton = mainFrame:addButton("buttonToAnimate")
+local aAnimation = mainFrame:addAnimation():setObject(testButton)
+
+local function easeInBack(t) -- t is the time from 0 to 1
+ local c1 = 1.70158;
+ local c3 = c1 + 1
+ return c3*t^3-c1*t^2
+end
+
+aAnimation:addMode("coolEaseInBack", easeInBack)
+aAnimation:setMode("coolEaseInBack"):move(15,3,2):play()
+```
diff --git a/docs/objects/Animation/onStart.md b/docs/objects/Animation/onStart.md
new file mode 100644
index 0000000..87540a9
--- /dev/null
+++ b/docs/objects/Animation/onStart.md
@@ -0,0 +1,16 @@
+## onStart
+`onStart(self)`
+This is a event which gets fired as soon as the animation is started.
+
+```lua
+local basalt = require("Basalt")
+
+local mainFrame = basalt.createFrame()
+local testButton = mainFrame:addButton("buttonToAnimate")
+local aAnimation = mainFrame:addAnimation():setObject(testButton):changeTextColor({colors.red, colors.yellow, colors.green}, 2)
+aAnimation:onStart(function()
+ basalt.debug("The animation is started")
+end)
+
+aAnimation:play()
+```
diff --git a/docs/objects/Animation/setMode.md b/docs/objects/Animation/setMode.md
new file mode 100644
index 0000000..399bd05
--- /dev/null
+++ b/docs/objects/Animation/setMode.md
@@ -0,0 +1,36 @@
+## setMode
+Changes the easing curve. If you want to test them, here is a interesting website: https://easings.co
+
+#### Parameters:
+1. `string` - The name of the curve you want to use.
+
+#### Returns:
+1. `animation` Animation in use
+
+#### Usage:
+* Takes 2 seconds to move the object from its current position to x15 y3
+```lua
+local mainFrame = basalt.createFrame()
+local testButton = mainFrame:addButton("buttonToAnimate")
+local aAnimation = mainFrame:addAnimation():setObject(testButton):setMode("easeInBounce"):move(15,3,2):play()
+```
+
+## Easing Curve List
+
+Here is a list of all available easing curves:
+
+| | | |
+|---|---|---|
+|linear||
+|easIn|easeOut|easeInOut
+|easeInSine|easeOutSine|easeInOutSine
+|easeInBack|easeOutBack|easeInOutBack
+|easeInCubic|easeOutCubic|easeInOutCubic
+|easeInElastic|easeOutElastic|easeInOutElastic
+|easeInExpo|easeOutExpo|easeInOutExpo
+|easeInBack|easeOutBack|easeInOutBack
+|easeInQuad|easeOutQuad|easeInOutQuad
+|easeInQuint|easeOutQuint|easeInOutQuint
+|easeInQuart|easeOutQuart|easeInOutQuart
+|easeInCirc|easeOutCirc|easeInOutCirc
+|easeInBounce|easeOutBounce|easeInOutBounce
diff --git a/docs/objects/Basalt.md b/docs/objects/Basalt.md
index 4f012ec..8d3db20 100644
--- a/docs/objects/Basalt.md
+++ b/docs/objects/Basalt.md
@@ -27,6 +27,8 @@ You are now able to access the following list of methods:
|[schedule](objects/Basalt/schedule.md)|Schedules a new task
|[setActiveFrame](objects/Basalt/setActiveFrame.md)|Sets the active frame
|[setTheme](objects/Basalt/setTheme.md)|Changes the base theme of basalt
+|[setMouseDragThrottle](objects/Basalt/setMouseDragThrottle.md)|Changes the mouse drag throttle amount
+|[setMouseMoveThrottle](objects/Basalt/setMouseMoveThrottle.md)|CraftOS-PC: Changes the mouse move throttle amount
|[setVariable](objects/Basalt/setVariable.md)|Sets a variable which you can access via XML
|[stopUpdate / stop](objects/Basalt/stopUpdate.md)|Stops the currently active event and draw listener
|[update](objects/Basalt/update.md)|Starts the event and draw listener once
diff --git a/docs/objects/Basalt/setMouseDragThrottle.md b/docs/objects/Basalt/setMouseDragThrottle.md
new file mode 100644
index 0000000..3909982
--- /dev/null
+++ b/docs/objects/Basalt/setMouseDragThrottle.md
@@ -0,0 +1,18 @@
+# Basalt
+
+## setMouseDragThrottle
+
+Changes the drag throttle of all drag events. Default value is 50ms - which is 0.05s.
+Instead of sending all mouse_drag events to the :onDrag handlers basalt sends every 0.05s (while dragging) the most recent drag event to all
+drag handlers. If you need all drag events - just change the value to 0.
+
+### Parameters
+
+1. `number` A number in miliseconds.
+
+### Usage
+
+```lua
+local basalt = require("basalt")
+basalt.setMouseDragThrottle(0)
+```
diff --git a/docs/objects/Basalt/setMouseMoveThrottle.md b/docs/objects/Basalt/setMouseMoveThrottle.md
new file mode 100644
index 0000000..7c533b9
--- /dev/null
+++ b/docs/objects/Basalt/setMouseMoveThrottle.md
@@ -0,0 +1,20 @@
+# Basalt
+
+## setMouseMoveThrottle
+
+This feature is only available for [CraftOS-PC](https://www.craftos-pc.cc).
+
+CraftOS-PC has a builtin mouse_move event, which is disabled by default. By using this method it will also enable the event for you. Remember - basalt does not disable the event after closing the program, which means the event stays active. If you want to disable the event please use config.set("mouse_move_throttle", -1) in your lua prompt or your program.
+
+Sidenote: a very low amount can make the program laggy - because it litterally spams the mouse_move event. So use it carefully.
+
+### Parameters
+
+1. `number` A number in miliseconds.
+
+### Usage
+
+```lua
+local basalt = require("basalt")
+basalt.setMouseMoveThrottle(50)
+```
diff --git a/docs/objects/Object.md b/docs/objects/Object.md
index 74afb2e..55dc2f3 100644
--- a/docs/objects/Object.md
+++ b/docs/objects/Object.md
@@ -40,6 +40,8 @@ This is a list of all available events for all objects:
|[onRelease](objects/Object/onRelease.md)|Fires as soon as the mouse button gets released
|[onScroll](objects/Object/onScroll.md)|Fires as soon as you scroll with the mousewheel
|[onDrag](objects/Object/onDrag.md)|Fires as soon as the object is beeing dragged
+|[onHover](objects/Object/onHover.md)|CraftOS-PC - fires when the mouse hovers over a object
+|[onLeave](objects/Object/onLeave.md)|CraftOS-PC - fires when the mouse leaves a object
|[onKey](objects/Object/onKey.md)|Fires when the object is focused and a keyboard key has been clicked
|[onChar](objects/Object/onChar.md)|Fires when the object is focused and a character has been clicked
|[onKeyUp](objects/Object/onKeyUp.md)|Fires when the object is focused and a keyboard key has been released
diff --git a/docs/objects/Object/onHover.md b/docs/objects/Object/onHover.md
new file mode 100644
index 0000000..c3bb2f3
--- /dev/null
+++ b/docs/objects/Object/onHover.md
@@ -0,0 +1,21 @@
+# onHover
+
+`onHover(self, event, button, x, y)`
+The computercraft event which triggers this method is `mouse_move` - only available in [CraftOS-PC](https://www.craftos-pc.cc).
+
+Here is a example on how to add a onHover event to your button:
+
+```lua
+local basalt = require("basalt")
+
+local main = basalt.createFrame()
+local button = main:addButton()
+ :setPosition(3,3)
+ :setSize(12,3)
+ :setText("Hover")
+
+function buttonOnHover()
+ basalt.debug("The mouse hovers over the button!")
+end
+button:onHover(buttonOnHover)
+```
diff --git a/docs/objects/Object/onLeave.md b/docs/objects/Object/onLeave.md
new file mode 100644
index 0000000..974af68
--- /dev/null
+++ b/docs/objects/Object/onLeave.md
@@ -0,0 +1,21 @@
+# onLeave
+
+`onLeave(self, event, button, x, y)`
+The computercraft event which triggers this method is `mouse_move` - only available in [CraftOS-PC](https://www.craftos-pc.cc).
+
+Here is a example on how to add a onLeave event to your button:
+
+```lua
+local basalt = require("basalt")
+
+local main = basalt.createFrame()
+local button = main:addButton()
+ :setPosition(3,3)
+ :setSize(12,3)
+ :setText("Leave")
+
+function buttonOnLeave()
+ basalt.debug("The mouse left the button!")
+end
+button:onLeave(buttonOnLeave)
+```
diff --git a/docs/objects/Program.md b/docs/objects/Program.md
index 1ae7c22..99a9576 100644
--- a/docs/objects/Program.md
+++ b/docs/objects/Program.md
@@ -12,6 +12,7 @@ Program objects are here for opening other executable programs in your main prog
|[injectEvent](objects/Program/injectEvent.md)|Injects a event into the program
|[injectEvents](objects/Program/injectEvents.md)|Injects a table of events
|[getQueuedEvents](objects/Program/getQueuedEvents.md)|Returns currently queued events
+|[setEnviroment](objects/Program/setEnviroment.md)|CHanges the default enviroment to a custom one
# Events
diff --git a/docs/objects/Program/setEnviroment.md b/docs/objects/Program/setEnviroment.md
new file mode 100644
index 0000000..fb95077
--- /dev/null
+++ b/docs/objects/Program/setEnviroment.md
@@ -0,0 +1,10 @@
+## setEnviroment
+Changes the default enviroment to a custom enviroment
+
+#### Parameters:
+
+1. `table` - Enviroment table
+
+#### Returns:
+
+1. `program` Program in use