java.lang.Object | |
↳ | net.pierrox.lightning_launcher.script.api.Item |
Known Direct Subclasses |
Known Indirect Subclasses |
The item is the base class for other objects that can be found in a container (shortcuts, folders, etc.).
There are specific classes for some items (shortcut, folder, ...) when these items provides custom services.
Some other item types don't have a specific class when they don't have more properties (such as widget for instance).
Since Lightning V14 allows the same container to be displayed multiple times on the same screen, it is possible to retrieve
several Item objects linked with the same underlying data. The identifier (see getId()
) will then be the same.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Scriptable |
extend()
Return a new script object, with this item as prototype
| ||||||||||
Array |
getAllBindings()
This method is deprecated.
use #getBindings instead
| ||||||||||
Binding |
getBindingByTarget(String target)
Retrieve a binding by its key, the taget.
| ||||||||||
Binding[] | getBindings() | ||||||||||
Image |
getBoxBackground(String state)
Retrieve the image currently displayed as the box background.
| ||||||||||
RectL |
getCell()
Returns the cell allocated to this item (only works when attached to the grid).
| ||||||||||
int |
getHeight()
Returns this item view height.
| ||||||||||
int |
getId()
Returns the unique item identifier.
| ||||||||||
Scriptable |
getMy()
Return a scriptable object that can be used to store live data.
| ||||||||||
String | getName() | ||||||||||
Container |
getParent()
Returns the container containing this item.
| ||||||||||
float | getPositionX() | ||||||||||
float | getPositionY() | ||||||||||
PropertySet |
getProperties()
Retrieve properties for this item.
| ||||||||||
View |
getRootView()
Retrieve the root android View for this item.
| ||||||||||
float |
getRotation()
Returns the rotation angle in degrees.
| ||||||||||
float |
getScaleX()
Returns the X scale for this item (only when detached from the grid).
| ||||||||||
float |
getScaleY()
Returns the Y scale for this item (only when detached from the grid).
| ||||||||||
Screen | getScreen() | ||||||||||
float |
getSkewX()
Returns the X skew for this item (only when detached from the grid).
| ||||||||||
float |
getSkewY()
Returns the Y skew for this item (only when detached from the grid).
| ||||||||||
String |
getTag()
Returns the value associated with this item.
| ||||||||||
String |
getTag(String id)
Returns the value associated with this item and id.
| ||||||||||
String |
getType()
Returns the item type has a text
| ||||||||||
int |
getWidth()
Returns this item view width.
| ||||||||||
boolean |
isVisible()
Returns true if the item is visible.
| ||||||||||
void |
setBinding(Binding binding)
Set a binding (same as #setBinding(String, String, boolean).
| ||||||||||
void |
setBinding(String target, String formula, boolean enabled)
Add or update a binding for this item.
| ||||||||||
void |
setBoxBackground(Image image, String state, boolean persistent)
Set a background image, optionally saving the change to file.
| ||||||||||
void |
setBoxBackground(Image image, String state)
Set a background image, in memory only, changes will not be persisted and will be lost when the app is restarted.box
| ||||||||||
void |
setCell(int left, int top, int right, int bottom)
Set the cell allocated to the item on the grid (only works when attached to the grid).
| ||||||||||
void |
setCell(int left, int top, int right, int bottom, boolean portrait)
Set the cell allocated to the item on the grid (only works when attached to the grid), persistently
| ||||||||||
void | setName(String name) | ||||||||||
void |
setPosition(float x, float y)
Set the position of the item (only when detached from the grid).
| ||||||||||
void |
setRotation(float angle)
Set the rotation of the item around its center (only when detached from the grid).
| ||||||||||
void |
setScale(float scaleX, float scaleY)
Set the scale of the item (only when detached from the grid).
| ||||||||||
void |
setSize(float width, float height)
Set the size of the item (only when detached from the grid).
| ||||||||||
void |
setSkew(float skewX, float skewY)
Set the skew of the item (only when detached from the grid).
| ||||||||||
void |
setTag(String id, String value)
Set a persistent data for this item.
| ||||||||||
void |
setTag(String value)
Set a persistent data for this item.
| ||||||||||
void |
setVisibility(boolean visible)
Hide or show an item.
| ||||||||||
String |
toString()
| ||||||||||
void |
unsetBinding(String target)
Removes a binding for this item.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Return a new script object, with this item as prototype
This method is deprecated.
use #getBindings instead
Retrieve the list of configured bindings.
Retrieve a binding by its key, the taget.
Retrieve the image currently displayed as the box background. This image can be shared amongst several items.
state | one of "n" (normal), "s" (selected) or "f" (focused) |
---|
Returns the cell allocated to this item (only works when attached to the grid).
Returns this item view height.
Returns the unique item identifier. Each item has its own unique id in the app, meaning that it is not possible to find 2 items in 2 containers with the same id. However the item id will change if it is moved from one desktop to another, or moved in/out of a folder or panel. It may also change when loaded from a template.
Return a scriptable object that can be used to store live data. These data won't be stored, unlike tags.
Retrieve properties for this item. Please note that modifying properties is expensive and not well suited for item animation.
Retrieve the root android View for this item.
Returns the rotation angle in degrees.
Returns the X scale for this item (only when detached from the grid).
Returns the Y scale for this item (only when detached from the grid).
Returns the X skew for this item (only when detached from the grid).
Returns the Y skew for this item (only when detached from the grid).
Returns the value associated with this item. This is the same as getTag(null);
Returns the value associated with this item and id. Can be undefined if it has never been set.
Using a null id is the same as calling getTag()
without argument
Returns the item type has a text
Returns this item view width.
Set a binding (same as #setBinding(String, String, boolean). It is forbidden to modify bindings in a script itself triggered by a binding.
Add or update a binding for this item.
It is forbidden to modify bindings in a script itself triggered by a binding.
The target name may be a property name, but not always. Although using any known property may work, only the list below is supported.
Common item properties
Name | Description |
i.alpha | Transparency |
i.visibility | Visibility |
i.enabled | Enabled |
i.zindex | Z-Index |
i.box | Box |
v | Dummy target |
Name | Description |
c.l | Cell left |
c.t | Cell top |
c.r | Cell right |
c.b | Cell bottom |
Name | Description |
t.x | Left (X) |
t.y | Top (Y) |
t.w | Width |
t.h | Height |
t.a | Angle |
t.sx | Scale X |
t.sy | Scale Y |
t.kx | Skew X |
t.ky | Skew Y |
Name | Description |
s.label | Label |
s.labelVisibility | Label visibility |
s.labelFontColor | Label color (normal state) |
s.selectionColorLabel | Label color (selected state) |
s.focusColorLabel | Label color (focused state) |
s.labelFontSize | Label font size |
s.labelFontStyle | Label font style |
Name | Description |
s.iconVisibility | Icon visibility |
s.iconScale | Icon scale |
s.iconReflection | Icon reflection |
s.iconColorFilter | Icon color filter |
Name | Description |
f.titleVisibility | Title visibility |
f.titleFontColor | Title font color |
f.titleFontSize | Title font size |
f.wAH | Horizontal alignment |
f.wAV | Vertical alignment |
f.wX | Left |
f.wY | Top |
f.wW | Width |
f.wH | Height |
f.box | Box |
target | the item's property to change (no check is done on this parameter) |
---|---|
formula | the value for the target, a constant value, a short or complex script |
enabled | whether this binding is active |
Set a background image, optionally saving the change to file. Note that saving the image to file is much slower than setting it in memory only, hence this is not suitable for animations.
state | a combination of "n" (normal), "s" (selected), "f" (focused) |
---|---|
persistent | whether to save changes and affect only this item, when set to false the image will be reset upon the next launcher restart |
Set a background image, in memory only, changes will not be persisted and will be lost when the app is restarted.box
state | a combination of "n" (normal), "s" (selected), "f" (focused) |
---|
Set the cell allocated to the item on the grid (only works when attached to the grid). These size and position are transcient and will be lost when the container is reloaded. Use the alternate setCell method to persist changes.
left | left column |
---|---|
top | top row |
right | right column |
bottom | bottom row |
Set the cell allocated to the item on the grid (only works when attached to the grid), persistently
left | left column |
---|---|
top | top row |
right | right column |
bottom | bottom row |
portrait | if true will set the portrait position (and landscape if not using dual position), if false will set the landscape position (only if using dual position) |
Set the position of the item (only when detached from the grid). Warning: any changes made through this method may be saved, meaning that the item position will have to be manually reset.
Set the rotation of the item around its center (only when detached from the grid). Warning: any changes made through this method may be saved, meaning that the item angle will have to be manually reset.
angle | in degrees |
---|
Set the scale of the item (only when detached from the grid). Warning: any changes made through this method may be saved, meaning that the item scale will have to be manually reset.
Set the size of the item (only when detached from the grid). Warning: any changes made through this method may be saved, meaning that the item size will have to be manually reset.
Set the skew of the item (only when detached from the grid). Warning: any changes made through this method may be saved, meaning that the item skew will have to be manually reset.
Set a persistent data for this item. This string value can be used to store non volatile data. Use JSON to store complex structures.
The data to store is associated with an identifier. This identifier is useful to reduce conflicts when multiple scripts need to use data for an item.
Using a null id is the same as calling setTag(String)
without the id argument.
Use setTag(id, null) to clear a tag.
Example of use:
// store some simple text var name = prompt("What is your name ?", "your name here"); item.setTag("my_value", name); // later, retrieve this text and display it on a shortcut var name = item.getTag("my_value"); other_item.setLabel(name); // store more than a string var complex_data = new Object(); complex_data.date = new Date(); complex_data.x = 4; complex_data.done = true; item.setTag("my_value", JSON.stringify(complex_data)); // load these data var complex_data = JSON.parse(item.getTag("my_value"));
id | identifier for this tag, valid characters are a-z, A-Z, 0-9 and _ (underscore). The identifier "_" is reserved and shouldn't be used. |
---|---|
value | value to store |
Set a persistent data for this item. This is the same as setTag(null, value)
Removes a binding for this item. It is forbidden to modify bindings in a script itself triggered by a binding.
target | target property for which to remove the binding |
---|