rex_gridCtrl
Plugin, ACE table, Discussion thread
Dependence: None
Dependence: None
Introduction
Manipulate instances of each grid in a table.
Manipulate instances of each grid in a table.
Concept
This plugin is improved from rex_listCtrl plugin.
Grid table is composed of some cells. Each cell is composed of data and instances like sprites and texts.
The physical boundary of this grid table control plugin is a visible area of this table, cells which out of this area are invisible.
User creates instances of each visible cell, and registers them to this plugin, then this plugin will set the position of these registered instances. And these registered instances will be destroyed while the cell is invisible by this plugin automatically.
Properties of instances in a cell are saved into this grid table control plugin instead of saving in private variables in the instances. So the instances only are used in displaying.
This plugin is improved from rex_listCtrl plugin.
Grid table is composed of some cells. Each cell is composed of data and instances like sprites and texts.
The physical boundary of this grid table control plugin is a visible area of this table, cells which out of this area are invisible.
User creates instances of each visible cell, and registers them to this plugin, then this plugin will set the position of these registered instances. And these registered instances will be destroyed while the cell is invisible by this plugin automatically.
Properties of instances in a cell are saved into this grid table control plugin instead of saving in private variables in the instances. So the instances only are used in displaying.
Usage
Sample capx
Sample capx
On a cell is visible
"Condition:On cell visible" will be triggered while the cell becomes visible. Create instances of this cell under this event. There are some expressions for this cell -
"Condition:On cell visible" will be triggered while the cell becomes visible. Create instances of this cell under this event. There are some expressions for this cell -
Expression:CellIndex - the index of this visible cell
( Expression:CellTLX, Expression:CellTLY ) - the position of the cell's top-left point
Then use "Action:Pin instance" to pin instances at this cell.
On a cell is invisible
"Condition:On cell invisible" will be triggered while a cell becomes invisible. Pinned instances will be destroyed automatically.
The cell index could be got by "Expression:CellIndex".
"Condition:On cell invisible" will be triggered while a cell becomes invisible. Pinned instances will be destroyed automatically.
The cell index could be got by "Expression:CellIndex".
Retrieve visible cells
Retrieve visible cells by "Condition:For each visible cell", get the cell index by "Expression:CellIndex" and the position of the cell's top-left point by ( Expression:CellTLX, Expression:CellTLY ) under this event.
Retrieve visible cells by "Condition:For each visible cell", get the cell index by "Expression:CellIndex" and the position of the cell's top-left point by ( Expression:CellTLX, Expression:CellTLY ) under this event.
Get cell index
Call "Expression:UID2CellIndex" to get the pinned instance is belong to which cell.
Call "Expression:UID2CellIndex" to get the pinned instance is belong to which cell.
Pick pined instances
"Condition:Pick instances", "Action:Pick instance", or "Condition:Pick all instances", "Action:Pick all instances" could be used to pick pined instances on a cell.
"Condition:Pick instances", "Action:Pick instance", or "Condition:Pick all instances", "Action:Pick all instances" could be used to pick pined instances on a cell.
Data of each cell
Data of each cell is stored in other data structure, like official array, official dictionary, rex_csv, etc... which indexes by cell index.
Properties of instances (for example, "is selected" state in a sprite) in each cell is stored/read in custom data of this plugin by "Action:Set value"/"Expression:At".
It is better NOT to use private variable to save properties in these instances in a cell, because that instances in a cell will be destroyed when the line is invisible.
Data of each cell is stored in other data structure, like official array, official dictionary, rex_csv, etc... which indexes by cell index.
Properties of instances (for example, "is selected" state in a sprite) in each cell is stored/read in custom data of this plugin by "Action:Set value"/"Expression:At".
It is better NOT to use private variable to save properties in these instances in a cell, because that instances in a cell will be destroyed when the line is invisible.
Retrieve filter cells
"Condition:For each matched cells" could be used to retrieve cells which the value in custom data is matched the condition. Get the cell index by "Expression:CellIndex".
"Condition:For each matched cells" could be used to retrieve cells which the value in custom data is matched the condition. Get the cell index by "Expression:CellIndex".
Scroll table
The table is scrolled by an offset (x, y), which is the (top-left) position of line index 0. Call one of these actions to set the offset (x, y) -
The table is scrolled by an offset (x, y), which is the (top-left) position of line index 0. Call one of these actions to set the offset (x, y) -
- Action:Set OX, Action:Set OY, Action:Set OXY
- Action:Add to OX, Action:Add to OY, Action:Add to OXY
- Action:Scroll to index
- Action:Scroll by percentage
Clamp offset (x,y)
Set "Clamp OXY" to "Yes" could clamp the visible cell between first to last line.
Set to "No" if user wants to control the offset (x,y) without any default constraint.
Set "Clamp OXY" to "Yes" could clamp the visible cell between first to last line.
Set to "No" if user wants to control the offset (x,y) without any default constraint.
Total cells
Set total cells count in "Total cells" in properties table, or set by "Action:Set total cells count".
Set total cells count in "Total cells" in properties table, or set by "Action:Set total cells count".
Retrieve cells
"Condition:For each cell" could retrieve each cell in this table, or use "Condition:For each cell in a range" to retrieve some cells.
Get the cell index by "Expression:CellIndex".
"Condition:For each cell" could retrieve each cell in this table, or use "Condition:For each cell in a range" to retrieve some cells.
Get the cell index by "Expression:CellIndex".
Cell size
The cell size is set in "Cell height", "Cell width" in properties table, or set by "Action:Set cell height", "Action:Set cell width".
The cell size is set in "Cell height", "Cell width" in properties table, or set by "Action:Set cell height", "Action:Set cell width".
Refresh visible cells
Call "Action:Refresh" to refresh visible cells by these steps
Call "Action:Refresh" to refresh visible cells by these steps
- Set all visible cells to invisible, it will destroy all instances in current visible cells.
- Get visible cells. it will create all instances in these new visible cells.
List height, list width
Get list height or list width by "Expression:ListHeight", "Expression:ListWidth".
Get list height or list width by "Expression:ListHeight", "Expression:ListWidth".
Remove cells
Call "Action:Remove cells" to remove cells from a start index. It will also destroy instances which belong these removed cells.
The custom data of these removed cells will also be removed, and packed into a string which could be read by "Expression:LastRemovedCells". It could be used to insert to another table, see next section.
Call "Action:Remove cells" to remove cells from a start index. It will also destroy instances which belong these removed cells.
The custom data of these removed cells will also be removed, and packed into a string which could be read by "Expression:LastRemovedCells". It could be used to insert to another table, see next section.
Insert cells
Call "Action:Insert new cells" or "Action:Push new cells" to insert some new cells with empty custom data.
Or call "Action:Insert cells" or "Action:Push cells" to insert some new cells with packed custom data. Packed custom data might come from "Expression:CustomDataInCells" or "Expression:LastRemovedCells".
Call "Action:Insert new cells" or "Action:Push new cells" to insert some new cells with empty custom data.
Or call "Action:Insert cells" or "Action:Push cells" to insert some new cells with packed custom data. Packed custom data might come from "Expression:CustomDataInCells" or "Expression:LastRemovedCells".
Move cells from one table to another
Here is a solution to move cells from source table to target table:
Here is a solution to move cells from source table to target table:
- Insert data to another data structure (official array object in this sample), and insert the custom data of these cells by "Expression:CustomDataInCells" to target table.
- Remove data and cells from source table.
Destroy
All pined object in each cell would be destroyed while gridCtrl object had been destroyed by action:Destroy.
All pined object in each cell would be destroyed while gridCtrl object had been destroyed by action:Destroy.
Scrolling horizontal
Sample capx
Set "Axis" to "Horizontal" in properties table to scroll lines horizontally.
Sample capx
Set "Axis" to "Horizontal" in properties table to scroll lines horizontally.