1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace ManiaLive\Gui\Windows;
13:
14: use ManiaLib\Gui\Elements\Bgs1InRace;
15: use ManiaLib\Gui\Elements\Icons128x128_Blink;
16: use ManiaLib\Gui\Elements\Icons64x64_1;
17: use ManiaLib\Gui\Elements\Label;
18: use ManiaLive\Gui\Controls\Frame;
19:
20: 21: 22: 23: 24:
25: final class Thumbnail extends \ManiaLive\Gui\Window
26: {
27: private $window;
28: private $isHighlighted;
29:
30: private $windowContent;
31: private $border;
32: private $buttonClose;
33: private $buttonCloseBg;
34: private $highlight;
35:
36: protected function onConstruct($window = null)
37: {
38: $this->window = $window;
39: $this->isHighlighted = false;
40:
41: $this->highlight = new Icons128x128_Blink();
42: $this->highlight->setSubStyle(Icons128x128_Blink::ShareBlink);
43: $this->addComponent($this->highlight);
44:
45: $this->border = new Bgs1InRace();
46: $this->border->setSubStyle(Bgs1InRace::BgTitleShadow);
47: $this->border->setAction($window->createAction(array($window, 'show')));
48: $this->addComponent($this->border);
49:
50: $this->windowContent = new Frame();
51: $this->windowContent->setAlign('center', 'center');
52: $this->windowContent->setSize($window->getSizeX(), $window->getSizeY());
53: foreach($window->getComponents() as $component)
54: $this->windowContent->addComponent($component);
55: $this->windowContent->disableLinks();
56: $this->addComponent($this->windowContent);
57:
58: $this->buttonCloseBg = new Bgs1InRace(4, 4);
59: $this->buttonCloseBg->setSubStyle(Bgs1InRace::BgTitleShadow);
60: $this->buttonCloseBg->setAlign('center', 'center');
61: $this->buttonCloseBg->setAction($this->createAction(array($this, 'hide')));
62: $this->addComponent($this->buttonCloseBg);
63:
64: $this->buttonClose = new Icons64x64_1(4);
65: $this->buttonClose->setAlign('center', 'center');
66: $this->buttonClose->setSubStyle(Icons64x64_1::QuitRace);
67: $this->addComponent($this->buttonClose);
68: }
69:
70: function getWindow()
71: {
72: return $this->window;
73: }
74:
75: 76: 77: 78:
79: function onDraw()
80: {
81: $this->highlight->setVisibility($this->isHighlighted);
82: }
83:
84: protected function onResize($oldX, $oldY)
85: {
86:
87: $this->buttonClose->setPosition($this->sizeX - 2, 2 - $this->sizeY);
88: $this->buttonCloseBg->setPosition($this->sizeX - 2, 2 - $this->sizeY);
89: $this->windowContent->setPosition($this->sizeX / 2, -$this->sizeY / 2);
90: $this->highlight->setSize($this->sizeX, $this->sizeY);
91: $this->border->setSize($this->sizeX, $this->sizeY);
92:
93:
94: $factorX = ($this->sizeX - 2) / $this->window->getSizeX();
95: $factorY = ($this->sizeY - 2) / $this->window->getSizeY();
96: $this->windowContent->setScale(min($factorX, $factorY));
97: }
98:
99: function destroy()
100: {
101: $this->window = null;
102: $this->windowContent->clearComponents();
103: parent::destroy();
104: }
105:
106: function enableHighlight()
107: {
108: $this->isHighlighted = true;
109: $this->redraw();
110: }
111:
112: function disableHighlight()
113: {
114: $this->isHighlighted = false;
115: $this->redraw();
116: }
117: }
118:
119: ?>