mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 13:15:50 +00:00
New UI (#367)
* Add Flipper * Remove old UI * Add boilerplate UI * Change plugin version * Merge upstream * Bunch of new UI changes Too lazy to list them all in individual commits * Touch ripple for buttons and a few other things * Make the close button on the PluginGui work * Set button state to guiEnabled * Implement Connecting, NotConnected; add Header; don't update plugin button on render * Replace mapLerpColor with mapLerp * Update blendAlpha to be 0 without any values * Add ActionFillTransparency to Theme.Button * Suffix all Theme entries * Update Flipper * Add disconnect button * Remove cancel button * Add settings page * Add scrollbar and dark theme support to settings * Include settings in startSession * Set context default value to nil I always thought this was the name, lol... * Add Error page * Fix preloadAssets * Fix preloadAssets import * Update checkbox colors a little * Add setting descriptions * Fix scrolling frame in settings panel * Remove .vscode * Rename Throbber to Spinner * Update merge * Move Spinner images to assets * Change casing of directories * Remove old directories * Add comments to getDerivedStateFromProps * Account for offset in host TextBox size * Turn width variables into constants * Attempt to fix the comments * Add a missing comma in Settings * Remove a double space * Remove Dummy object * Move most of the Studio logic out of render * Don't truncate port input * Replace merge with Dictionary.merge * Replace "Got it!" with "Okay" * Add projectName to setStatus call * Add Flipper to build.rs
This commit is contained in:
58
plugin/src/App/bindingUtil.lua
Normal file
58
plugin/src/App/bindingUtil.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
|
||||
local Roact = require(Rojo.Roact)
|
||||
local Log = require(Rojo.Log)
|
||||
|
||||
local LERP_DATA_TYPES = {
|
||||
Color3 = true,
|
||||
UDim = true,
|
||||
UDim2 = true,
|
||||
Vector2 = true,
|
||||
Vector3 = true,
|
||||
}
|
||||
|
||||
local function fromMotor(motor)
|
||||
local motorBinding, setMotorBinding = Roact.createBinding(motor:getValue())
|
||||
motor:onStep(setMotorBinding)
|
||||
return motorBinding
|
||||
end
|
||||
|
||||
local function mapLerp(binding, value1, value2)
|
||||
local valueType = typeof(value1)
|
||||
if valueType ~= typeof(value2) then
|
||||
Log.error("Type mismatch between values ({}, {}})", valueType, typeof(value2))
|
||||
end
|
||||
|
||||
return binding:map(function(position)
|
||||
if valueType == "number" then
|
||||
return value1 - (value2 - value1) * position
|
||||
elseif LERP_DATA_TYPES[valueType] then
|
||||
return value1:lerp(value2, position)
|
||||
else
|
||||
Log.error("Unable to interpolate type {}", valueType)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function deriveProperty(binding, propertyName)
|
||||
return binding:map(function(values)
|
||||
return values[propertyName]
|
||||
end)
|
||||
end
|
||||
|
||||
local function blendAlpha(alphaValues)
|
||||
local alpha = 0
|
||||
|
||||
for _, value in pairs(alphaValues) do
|
||||
alpha = alpha + (1 - alpha) * value
|
||||
end
|
||||
|
||||
return alpha
|
||||
end
|
||||
|
||||
return {
|
||||
fromMotor = fromMotor,
|
||||
mapLerp = mapLerp,
|
||||
deriveProperty = deriveProperty,
|
||||
blendAlpha = blendAlpha,
|
||||
}
|
||||
Reference in New Issue
Block a user