Sorter
This component sorts the children of a Container (i.e. a Component
or a List
) according to a specified property.
Constructor
Sort <id> (Process container, string path_and_name_of_the_property)
Action
Sort the children of the given container according to the given path.Predefined children
- BoolProperty:
ascending
if true, sorts in the ascending order, otherwise sorts in the descending order. - TextProperty:
spec
path and name of the property used for the sort. - Spike:
sort
triggers the sort.
Example
use core
use base
use gui
_main_
Component root {
Frame f ("my frame", 0, 0, 400, 600)
Exit ex (0, 1)
f.close -> ex
FillColor _ (200, 50, 50)
OutlineColor _ (100, 100, 250)
FillOpacity _ (0.5)
List l {
Rectangle r1 (0, 0, 100, 40, 0, 0)
Rectangle r2 (0, 10, 50, 60, 0, 0)
Rectangle r3 (0, 20, 150, 90, 0, 0)
}
Sorter sorter (l, "width")
Timer t (1000)
AssignmentSequence change (1) {
"height" =: sorter.spec
}
t.end->change, sorter.sort
sorter.sort->(l) {
int y = 10
for (int i = 1; i <= l.size; i++) {
l.[i].y = y
y = y + 70
}
}
}