Completed
Pull Request — master (#139)
by De Cramer
02:36
created

WidgetBackground::getPosX()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace eXpansion\Framework\Gui\Builders;
4
5
use FML\Controls\Quad;
6
use FML\Types\Renderable;
7
8
class WidgetBackground implements Renderable
9
{
10
    protected $posX = 0;
11
    protected $posY = 0;
12
    protected $posZ = 0;
13
    protected $id;
14
    protected $width;
15
    protected $height;
16
    protected $action;
17
18
    /**
19
     * WidgetBackground constructor.
20
     * @param float $width
21
     * @param float $height
22
     */
23
    public function __construct($width, $height)
24
    {
25
        $this->width = $width;
26
        $this->height = $height;
27
    }
28
29
    /**
30
     * Render the XML element
31
     *
32
     * @param \DOMDocument $domDocument DOMDocument for which the XML element should be rendered
33
     * @return \DOMElement
34
     */
35
    public function render(\DOMDocument $domDocument)
36
    {
37
        $quad = Quad::create();
38
        $quad->setPosition($this->posX, $this->posY)->setZ($this->posZ)
39
            ->setOpacity(0.4)->setBackgroundColor("000");
40
        if ($this->id) {
41
            $quad->setId($this->id);
42
        }
43
        if ($this->action) {
44
            $quad->setAction($this->action)->setFocusBackgroundColor("999");
45
        }
46
47
        return $quad->render($domDocument);
48
    }
49
50
    /**
51
     * @return int
52
     */
53
    public function getPosX(): int
54
    {
55
        return $this->posX;
56
    }
57
58
    /**
59
     * @param int $posX
60
     */
61
    public function setPosX(int $posX)
62
    {
63
        $this->posX = $posX;
64
    }
65
66
    /**
67
     * @return int
68
     */
69
    public function getPosY(): int
70
    {
71
        return $this->posY;
72
    }
73
74
    /**
75
     * @param int $posY
76
     */
77
    public function setPosY(int $posY)
78
    {
79
        $this->posY = $posY;
80
    }
81
82
    /**
83
     * @return int
84
     */
85
    public function getPosZ(): int
86
    {
87
        return $this->posZ;
88
    }
89
90
    /**
91
     * @param int $posZ
92
     */
93
    public function setPosZ(int $posZ)
94
    {
95
        $this->posZ = $posZ;
96
    }
97
98
    /**
99
     * @return mixed
100
     */
101
    public function getWidth()
102
    {
103
        return $this->width;
104
    }
105
106
    /**
107
     * @param mixed $width
108
     */
109
    public function setWidth($width)
110
    {
111
        $this->width = $width;
112
    }
113
114
    /**
115
     * @return mixed
116
     */
117
    public function getHeight()
118
    {
119
        return $this->height;
120
    }
121
122
    /**
123
     * @param mixed $height
124
     */
125
    public function setHeight($height)
126
    {
127
        $this->height = $height;
128
    }
129
130
    /**
131
     * @return mixed
132
     */
133
    public function getAction()
134
    {
135
        return $this->action;
136
    }
137
138
    /**
139
     * @param mixed $action
140
     */
141
    public function setAction($action)
142
    {
143
        $this->action = $action;
144
    }
145
146
    /**
147
     * @return mixed
148
     */
149
    public function getId()
150
    {
151
        return $this->id;
152
    }
153
154
    /**
155
     * @param mixed $id
156
     */
157
    public function setId($id)
158
    {
159
        $this->id = $id;
160
    }
161
162
163
}
164