4.3.1r21
[enigma2.git] / usr / lib / enigma2 / python / Plugins / Extensions / Browser / BrowserVideoWindow.py
1 from enigma import ePoint, eSize, getDesktop
2 from Components.VideoWindow import VideoWindow
3 from Screens.Screen import Screen
4
5 from Tools.Log import Log
6
7 class BrowserVideoWindow(Screen):
8         skin = """
9                 <screen name="HbbTVVideoWindow" flags="wfNoBorder" zPosition="-1" position="0,0" size="1280,720" title="HbbTVVideoWindow" transparent="1">
10                         <widget name="video" position="0,0" zPosition="0" size="0,0" backgroundColor="transparent" transparent="1"/>
11                         <eLabel text="VIDEO HERE!" position="0,0" zPosition="1" size="200,30" font="Regular;18" foregroundColor="#7f848d" backgroundColor="#182946" />
12                 </screen>
13         """
14
15         def __init__(self, session, point=ePoint(0, 0), size=eSize(0, 0)):
16                 Screen.__init__(self, session)
17                 desktopSize = getDesktop(0).size()
18                 self["video"] = VideoWindow(decoder=0, fb_width=desktopSize.width(), fb_height=desktopSize.height())
19
20                 self.__point = point
21                 self.__size = size
22                 self.__retainedPoint = point
23                 self.__retainedSize = size
24
25                 self.__isFullscreen = False
26                 self.onLayoutFinish.append(self._onLayoutFinished)
27
28         def _onLayoutFinished(self):
29                 self.setRect(self.__point, self.__size, force=True)
30
31         def setRect(self, point, size, retain=True, force=False):
32                 Log.w("%s,%s %s x %s" %(point.x(), point.y(), size.width(), size.height()))
33                 if point.x() != self.__point.x() or point.y() != self.__point.y() or force:
34                         self.instance.move(point)
35                         self.__point = point
36                 if size.width() != self.__size.width() or size.height() != self.__size.height() or force:
37                         self.instance.resize(size)
38                         self.__size = size
39                         self["video"].instance.resize(size)
40
41                 if retain:
42                         self.__retainedPoint = point
43                         self.__retainedSize = size
44
45         def toggleFullscreen(self):
46                 if self.__isFullscreen:
47                         self.setRect(self.__retainedPoint, self.__retainedSize)
48                         self.__isFullscreen = False
49                 else:
50                         point = ePoint(0, 0)
51                         size = getDesktop(0).size()
52                         self.setRect(point, size, retain=False)
53                         self.__isFullscreen = True
54                 return self.__isFullscreen