-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPanelExample.php
More file actions
86 lines (71 loc) · 2.47 KB
/
PanelExample.php
File metadata and controls
86 lines (71 loc) · 2.47 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
<?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\Image;
use refaltor\ui\elements\Label;
use refaltor\ui\elements\Panel;
/**
* PanelExample - Demonstrates Panel features.
*
* Shows: nested panels, background images, alpha, clipping, child elements.
*/
class PanelExample implements RootBuild
{
public function root(): Root
{
$root = Root::create();
// Main container panel (fullscreen)
$mainPanel = Panel::create("main_panel")
->setSizePercentage(100, 100);
// Background image inside the panel
$bg = Image::create("bg_image", "textures/ui/background")
->setSizePercentage(100, 100)
->setKeepRatio(false)
->setNinesliceSize(4);
$mainPanel->addChild($bg);
// Inner panel with fixed size and alpha
$innerPanel = Panel::create("inner_panel")
->setSize(200, 150)
->setAlpha(0.9)
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
// Label inside inner panel
$label = Label::create("panel_title", "Inner Panel")
->setFontSize(Label::FONT_LARGE)
->setShadow()
->setColor(BasicColor::white())
->setAnchorFrom(Element::ANCHOR_TOP_MIDDLE)
->setAnchorTo(Element::ANCHOR_TOP_MIDDLE)
->setOffset(0, 5);
$innerPanel->addChild($label);
// Nested child panel with clipping enabled
$clippedPanel = Panel::create("clipped_panel")
->setSize(180, 80)
->setAnchorFrom(Element::ANCHOR_BOTTOM_MIDDLE)
->setAnchorTo(Element::ANCHOR_BOTTOM_MIDDLE)
->setOffset(0, -10);
$clippedLabel = Label::create("clipped_text", "This text is inside a clipped panel")
->setFontSize(Label::FONT_SMALL)
->setColor(BasicColor::cyan());
$clippedPanel->addChild($clippedLabel);
$innerPanel->addChild($clippedPanel);
$mainPanel->addChild($innerPanel);
$root->addElement($mainPanel);
return $root;
}
public function getNamespace(): string
{
return "panel_example";
}
public function getPathName(): string
{
return "./resources/pack_example/";
}
public function titleCondition(): string
{
return "PANEL_EXAMPLE";
}
}