-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathStackPanelExample.php
More file actions
97 lines (80 loc) · 2.83 KB
/
StackPanelExample.php
File metadata and controls
97 lines (80 loc) · 2.83 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace refaltor\roots;
use refaltor\ui\builders\Root;
use refaltor\ui\builders\RootBuild;
use refaltor\ui\colors\BasicColor;
use refaltor\ui\elements\Element;
use refaltor\ui\elements\Label;
use refaltor\ui\elements\Panel;
use refaltor\ui\elements\StackPanel;
use refaltor\ui\helpers\OrientationHelper;
/**
* StackPanelExample - Demonstrates StackPanel layouts.
*
* Shows: vertical stacking, horizontal stacking, nested stack panels.
*/
class StackPanelExample implements RootBuild
{
public function root(): Root
{
$root = Root::create();
// Vertical stack panel (menu-like layout)
$verticalStack = StackPanel::create("vertical_menu")
->setOrientation(OrientationHelper::VERTICAL)
->setSize(200, 200)
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
// Add labels as menu items
$item1 = Label::create("menu_item_1", "Play Game")
->setFontSize(Label::FONT_LARGE)
->setShadow()
->setColor(BasicColor::white())
->setSize(200, 30);
$verticalStack->addChild($item1);
$item2 = Label::create("menu_item_2", "Settings")
->setFontSize(Label::FONT_LARGE)
->setShadow()
->setColor(BasicColor::white())
->setSize(200, 30);
$verticalStack->addChild($item2);
$item3 = Label::create("menu_item_3", "Credits")
->setFontSize(Label::FONT_LARGE)
->setShadow()
->setColor(BasicColor::white())
->setSize(200, 30);
$verticalStack->addChild($item3);
$root->addElement($verticalStack);
// Horizontal stack panel (toolbar-like layout)
$horizontalStack = StackPanel::create("toolbar")
->setOrientation(OrientationHelper::HORIZONTAL)
->setCustomSize(["100%", 40])
->setAnchorFrom(Element::ANCHOR_BOTTOM_MIDDLE)
->setAnchorTo(Element::ANCHOR_BOTTOM_MIDDLE);
$btn1 = Label::create("tool_1", "Home")
->setColor(BasicColor::yellow())
->setSize(80, 40);
$horizontalStack->addChild($btn1);
$btn2 = Label::create("tool_2", "Inventory")
->setColor(BasicColor::cyan())
->setSize(80, 40);
$horizontalStack->addChild($btn2);
$btn3 = Label::create("tool_3", "Map")
->setColor(BasicColor::green())
->setSize(80, 40);
$horizontalStack->addChild($btn3);
$root->addElement($horizontalStack);
return $root;
}
public function getNamespace(): string
{
return "stackpanel_example";
}
public function getPathName(): string
{
return "./resources/pack_example/";
}
public function titleCondition(): string
{
return "STACKPANEL_EXAMPLE";
}
}