2 from Screens.Screen import Screen
3 from Screens.MessageBox import MessageBox
4 from Components.ActionMap import NumberActionMap
5 from Components.Label import Label
6 from Components.MenuList import MenuList
7 from Components.GUIComponent import *
8 from Components.ChoiceList import ChoiceEntryComponent, ChoiceList
12 # this is not so great.
20 def clip(val, min, max):
27 class PiPSetup(Screen):
28 def __init__(self, session, pip):
29 Screen.__init__(self, session)
33 self.pos = (self.pip.instance.position().x(), self.pip.instance.position().y())
34 self.size = self.pip.getSize()
36 self.orgpos = self.pos
37 self.orgsize = self.size
41 self["text"] = Label(_("Please use direction keys to move the PiP window.\nPress Bouquet +/- to resize the window.\nPress OK to go back to the TV mode or EXIT to cancel the moving."))
43 self["actions"] = NumberActionMap(["PiPSetupActions", "NumberActions"],
46 "cancel": self.cancel,
52 "size-": self.smaller,
53 "1": self.keyNumberGlobal,
54 "2": self.keyNumberGlobal,
55 "3": self.keyNumberGlobal,
56 "4": self.keyNumberGlobal,
57 "5": self.keyNumberGlobal,
58 "6": self.keyNumberGlobal,
59 "7": self.keyNumberGlobal,
60 "8": self.keyNumberGlobal,
61 "9": self.keyNumberGlobal,
62 "0": self.keyNumberGlobal
69 self.pos = self.orgpos
70 self.size = self.orgsize
74 def setPiPPosition(self):
75 self.pip.move(self.pos[0], self.pos[1])
76 self.pip.resize(self.size[0], self.size[1])
78 def resizePiP(self, resize):
79 resize += 100 # resize is in percent, so resize=+20 means: 120%
82 w = clip(self.size[0] * resize / 100, MIN_W, MAX_W)
83 h = clip(self.size[1] * resize / 100, MIN_H, MAX_H)
85 # calculate offset from center
86 mx = (oldsize[0] - w) / 2
87 my = (oldsize[1] - h) / 2
90 # reclip, account for new center
91 self.moveRelative(x=mx, y=my)
93 def moveRelative(self, x=0, y=0):
94 self.pos = (clip(self.pos[0] + x, 0, MAX_X - self.size[0]), clip(self.pos[1] + y, 0, MAX_Y - self.size[1]))
98 self.moveRelative(y=-32)
101 self.moveRelative(y=+32)
104 self.moveRelative(x=-24)
107 self.moveRelative(x=+24)
115 def keyNumberGlobal(self, number):
123 self.size = (180, 135)
125 # offset to keep center
126 ox = (colsize - self.size[0]) / 2
127 oy = (rowsize - self.size[1]) / 2
129 self.pos = (col * colsize + ox, row * rowsize + oy)
131 # restore old position
132 self.pos = self.orgpos
133 self.size = self.orgsize