-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGridExample.php
More file actions
67 lines (56 loc) · 1.75 KB
/
GridExample.php
File metadata and controls
67 lines (56 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace refaltor\roots;
use refaltor\ui\builders\Root;
use refaltor\ui\builders\RootBuild;
use refaltor\ui\elements\Element;
use refaltor\ui\elements\Grid;
use refaltor\ui\elements\Panel;
/**
* GridExample - Demonstrates Grid element features.
*
* Shows: grid dimensions, item templates, maximum items, fill direction.
*/
class GridExample implements RootBuild
{
public function root(): Root
{
$root = Root::create();
$panel = Panel::create("grid_container")
->setSizePercentage(100, 100);
// Basic 3x3 grid
$grid = Grid::create("inventory_grid")
->setGridDimensions([3, 3])
->setMaximumGridItems(9)
->setGridItemTemplate("common.inventory_slot")
->setGridFillDirection("horizontal")
->setGridRescalingType("horizontal")
->setSize(180, 180)
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
$panel->addChild($grid);
// Vertical grid for a list layout
$listGrid = Grid::create("list_grid")
->setGridDimensions([1, 5])
->setMaximumGridItems(5)
->setGridFillDirection("vertical")
->setSize(200, 250)
->setAnchorFrom(Element::ANCHOR_RIGHT_MIDDLE)
->setAnchorTo(Element::ANCHOR_RIGHT_MIDDLE)
->setOffset(-10, 0);
$panel->addChild($listGrid);
$root->addElement($panel);
return $root;
}
public function getNamespace(): string
{
return "grid_example";
}
public function getPathName(): string
{
return "./resources/pack_example/";
}
public function titleCondition(): string
{
return "GRID_EXAMPLE";
}
}