-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathInputPanelExample.php
More file actions
134 lines (114 loc) · 4.45 KB
/
InputPanelExample.php
File metadata and controls
134 lines (114 loc) · 4.45 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?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\InputPanel;
use refaltor\ui\elements\Label;
use refaltor\ui\elements\Panel;
/**
* InputPanelExample - Demonstrates InputPanel configurations.
*
* Shows: modal input panel, focus navigation, button mappings,
* gesture tracking, always handle pointer.
*/
class InputPanelExample implements RootBuild
{
public function root(): Root
{
$root = Root::create();
$mainPanel = Panel::create("input_panel_container")
->setSizePercentage(100, 100);
// Background
$bg = Image::create("input_bg", "textures/ui/dialog_background_opaque")
->setSizePercentage(100, 100)
->setNinesliceSize(4)
->setLayer(-1);
$mainPanel->addChild($bg);
// Title
$title = Label::create("input_title", "InputPanel Examples")
->setFontSize(Label::FONT_EXTRA_LARGE)
->setShadow()
->setColor(BasicColor::yellow())
->setAnchorFrom(Element::ANCHOR_TOP_MIDDLE)
->setAnchorTo(Element::ANCHOR_TOP_MIDDLE)
->setOffset(0, 10);
$mainPanel->addChild($title);
// Modal input panel (blocks input to elements behind)
$modalPanel = InputPanel::create("modal_dialog")
->setModal(true)
->setAlwaysListenToInput(true)
->setFocusEnabled(true)
->setFocusIdentifier("modal_focus")
->setDefaultFocusPrecedence(true)
->addButtonMapping("button.menu_cancel", "button.menu_exit", "pressed")
->addButtonMapping("button.menu_select", "button.menu_ok", "pressed")
->setSize(250, 180)
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
$modalLabel = Label::create("modal_label", "This is a modal dialog")
->setFontSize(Label::FONT_LARGE)
->setColor(BasicColor::white())
->setShadow()
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
$modalPanel->addChild($modalLabel);
$mainPanel->addChild($modalPanel);
// Non-modal input panel with focus navigation
$navPanel = InputPanel::create("nav_panel")
->setModal(false)
->setFocusEnabled(true)
->setFocusIdentifier("nav_focus")
->setFocusChangeUp("button_above")
->setFocusChangeDown("button_below")
->setFocusChangeLeft("button_left")
->setFocusChangeRight("button_right")
->setUseLastFocus(true)
->setSize(200, 60)
->setAnchorFrom(Element::ANCHOR_BOTTOM_LEFT)
->setAnchorTo(Element::ANCHOR_BOTTOM_LEFT)
->setOffset(10, -10);
$navLabel = Label::create("nav_label", "Focusable Panel")
->setFontSize(Label::FONT_NORMAL)
->setColor(BasicColor::cyan())
->setShadow()
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
$navPanel->addChild($navLabel);
$mainPanel->addChild($navPanel);
// Gesture tracking panel (for touch/drag interactions)
$gesturePanel = InputPanel::create("gesture_panel")
->setModal(false)
->setGestureTrackingButton(true)
->setAlwaysHandlePointer(true)
->setAlwaysListenToInput(true)
->setSize(200, 60)
->setAnchorFrom(Element::ANCHOR_BOTTOM_RIGHT)
->setAnchorTo(Element::ANCHOR_BOTTOM_RIGHT)
->setOffset(-10, -10);
$gestureLabel = Label::create("gesture_label", "Touch/Drag Area")
->setFontSize(Label::FONT_NORMAL)
->setColor(BasicColor::green())
->setShadow()
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
$gesturePanel->addChild($gestureLabel);
$mainPanel->addChild($gesturePanel);
$root->addElement($mainPanel);
return $root;
}
public function getNamespace(): string
{
return "inputpanel_example";
}
public function getPathName(): string
{
return "./resources/pack_example/";
}
public function titleCondition(): string
{
return "INPUTPANEL_EXAMPLE";
}
}