-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Custom controls variables
Duy Tran Khanh edited this page Nov 20, 2020
·
5 revisions
-
screen_width
: width of screen. -
screen_height
: height of screen.
-
width
: width of the control button itself. -
height
: height of the control button itself.
-
top
: top of screen, current is 0. -
left
: left of screen, current is 0. -
right
: right of screen, calculated as${screen_width} - ${width} - ${margin}
. -
bottom
: bottom of screen, calculated as${screen_height} - ${height} - ${margin}
.
-
margin
: margin, current is 2dp.
Currently, variables are only apply for Dynamic X and Y, which in format ${variable}
.
For example
"dynamicX": "${screen_width} - ${width} * 2 + ${margin}"
With these given properties:
- Screen width: 1280
- Button width: 100
- Margin: 2dp, convert into pixels unit: 4px
It will be converted into
"dynamicX": "1280 - 100 * 2 + 4"
Then, the x
field (stored in the memory when paste a control json) is being calculated from dynamicX
use exp4j.
ControlData controlData = ...
controlData.x = new ExpressionBuilder(controlData.dynamicX).build().evaluate();