1 from Screens.Screen import Screen
2 from Screens.MessageBox import MessageBox
3 from Components.ActionMap import ActionMap
4 from Components.ConfigList import ConfigListScreen
5 from Components.MenuList import MenuList
6 from Components.Sources.StaticText import StaticText
7 from Components.config import config, ConfigNumber, ConfigSelection, ConfigSelectionNumber, getConfigListEntry
8 from Plugins.Plugin import PluginDescriptor
10 from enigma import setAnimation_current, setAnimation_speed, setAnimation_current_listbox
12 # default = slide to left
20 g_animation_paused = False
24 config.misc.window_animation_default = ConfigNumber(default=g_default["current"])
25 config.misc.window_animation_speed = ConfigSelectionNumber(1, g_max_speed, 1, default=g_default["speed"])
26 config.misc.listbox_animation_default = ConfigSelection(default = g_default["listbox"], choices = [ ("0", _("Disable")), ("1", _("Enable")), ("2", _("Same behavior as current animation")) ])
28 class AnimationSetupConfig(ConfigListScreen, Screen):
30 <screen position="center,center" size="600,140" title="Animation Settings">
31 <widget name="config" position="0,0" size="600,100" scrollbarMode="showOnDemand" />
33 <ePixmap pixmap="skin_default/buttons/red.png" position="0,100" size="140,40" alphatest="on" />
34 <ePixmap pixmap="skin_default/buttons/green.png" position="140,100" size="140,40" alphatest="on" />
35 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,100" size="140,40" alphatest="on" />
37 <widget source="key_red" render="Label" position="0,100" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#9f1313" transparent="1" />
38 <widget source="key_green" render="Label" position="140,100" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#1f771f" transparent="1" />
39 <widget source="key_yellow" render="Label" position="280,100" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#a08500" transparent="1" />
43 def __init__(self, session):
44 self.session = session
47 Screen.__init__(self, session)
48 ConfigListScreen.__init__(self, self.entrylist)
50 self["actions"] = ActionMap(["OkCancelActions", "ColorActions",], {
52 "green" : self.keyGreen,
53 "yellow" : self.keyYellow,
55 "cancel" : self.keyRed,
57 self["key_red"] = StaticText(_("Cancel"))
58 self["key_green"] = StaticText(_("Save"))
59 self["key_yellow"] = StaticText(_("Default"))
62 self.onLayoutFinish.append(self.layoutFinished)
64 def layoutFinished(self):
65 self.setTitle(_('Animation Setup'))
68 config.misc.window_animation_speed.save()
69 setAnimation_speed(int(config.misc.window_animation_speed.value))
70 config.misc.listbox_animation_default.save()
71 setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
75 config.misc.window_animation_speed.cancel()
76 config.misc.listbox_animation_default.cancel()
82 config.misc.window_animation_speed.value = g_default["speed"]
83 config.misc.listbox_animation_default.value = g_default["listbox"]
87 ConfigListScreen.keyLeft(self)
90 ConfigListScreen.keyRight(self)
92 def makeConfigList(self):
95 entrySpeed = getConfigListEntry(_("Animation Speed"), config.misc.window_animation_speed)
96 self.entrylist.append(entrySpeed)
97 entryMoveSelection = getConfigListEntry(_("Enable Focus Animation"), config.misc.listbox_animation_default)
98 self.entrylist.append(entryMoveSelection)
100 self["config"].list = self.entrylist
101 self["config"].l.setList(self.entrylist)
104 class AnimationSetupScreen(Screen):
105 animationSetupItems = [
106 {"idx":0, "name":_("Disable Animations")},
107 {"idx":1, "name":_("Simple fade")},
108 {"idx":2, "name":_("Grow drop")},
109 {"idx":3, "name":_("Grow from left")},
110 {"idx":4, "name":_("Popup")},
111 {"idx":5, "name":_("Slide drop")},
112 {"idx":6, "name":_("Slide left to right")},
113 {"idx":7, "name":_("Slide top to bottom")},
114 {"idx":8, "name":_("Stripes")},
118 <screen name="AnimationSetup" position="center,center" size="580,400" title="Animation Setup">
119 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" zPosition="1" alphatest="on" />
120 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" zPosition="1" alphatest="on" />
121 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" zPosition="1" alphatest="on" />
122 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" zPosition="1" alphatest="on" />
124 <widget source="key_red" render="Label" position="0,0" zPosition="2" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#9f1313" transparent="1" />
125 <widget source="key_green" render="Label" position="140,0" zPosition="2" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#1f771f" transparent="1" />
126 <widget source="key_yellow" render="Label" position="280,0" zPosition="2" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#a08500" transparent="1" />
127 <widget source="key_blue" render="Label" position="420,0" zPosition="2" size="140,40" font="Regular;20" halign="center" valign="center" foregroundColor="#ffffff" backgroundColor="#18188b" transparent="1" />
129 <widget name="list" position="10,60" size="560,364" scrollbarMode="showOnDemand" />
130 <widget source="introduction" render="Label" position="0,370" size="560,40" zPosition="10" font="Regular;20" valign="center" backgroundColor="#25062748" transparent="1" />
133 def __init__(self, session):
135 self.skin = AnimationSetupScreen.skin
136 Screen.__init__(self, session)
138 self.animationList = []
140 self["introduction"] = StaticText(_("* current animation"))
141 self["key_red"] = StaticText(_("Cancel"))
142 self["key_green"] = StaticText(_("Save"))
143 self["key_yellow"] = StaticText(_("Setting"))
144 self["key_blue"] = StaticText(_("Preview"))
146 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
148 "cancel": self.keyclose,
151 "yellow": self.config,
155 self["list"] = MenuList(self.animationList)
157 self.onLayoutFinish.append(self.layoutFinished)
159 def layoutFinished(self):
161 for x in self.animationSetupItems:
162 key = x.get("idx", 0)
163 name = x.get("name", "??")
164 if key == config.misc.window_animation_default.value:
165 name = "* %s" % (name)
166 l.append( (name, key) )
168 self["list"].setList(l)
171 current = self["list"].getCurrent()
174 config.misc.window_animation_default.value = key
175 config.misc.window_animation_default.save()
176 setAnimation_current(key)
177 setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
181 setAnimation_current(config.misc.window_animation_default.value)
182 setAnimation_speed(int(config.misc.window_animation_speed.value))
183 setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
187 self.session.open(AnimationSetupConfig)
190 current = self["list"].getCurrent()
192 global g_animation_paused
193 tmp = g_animation_paused
194 g_animation_paused = False
196 setAnimation_current(current[1])
197 self.session.open(MessageBox, current[0], MessageBox.TYPE_INFO, timeout=3)
198 g_animation_paused = tmp
200 def checkAttrib(self, paused):
201 global g_animation_paused
202 if g_animation_paused is paused and self.skinAttributes is not None:
203 for (attr, value) in self.skinAttributes:
204 if attr == "animationPaused" and value in ("1", "on"):
208 def screen_show(self):
209 global g_animation_paused
210 if g_animation_paused:
211 setAnimation_current(0)
215 if checkAttrib(self, False):
216 g_animation_paused = True
218 def screen_doClose(self):
219 global g_animation_paused
220 if checkAttrib(self, True):
221 g_animation_paused = False
222 setAnimation_current(config.misc.window_animation_default.value)
225 def animationSetupMain(session, **kwargs):
226 session.open(AnimationSetupScreen)
228 def startAnimationSetup(menuid):
229 if menuid != "system":
232 return [( _("Animations"), animationSetupMain, "animation_setup", None)]
234 def sessionAnimationSetup(session, reason, **kwargs):
235 setAnimation_current(config.misc.window_animation_default.value)
236 setAnimation_speed(int(config.misc.window_animation_speed.value))
237 setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
239 global g_orig_show, g_orig_doClose
240 if g_orig_show is None:
241 g_orig_show = Screen.show
242 if g_orig_doClose is None:
243 g_orig_doClose = Screen.doClose
244 Screen.show = screen_show
245 Screen.doClose = screen_doClose
247 def Plugins(**kwargs):
251 description = "Setup UI animations",
252 where = PluginDescriptor.WHERE_MENU,
253 needsRestart = False,
254 fnc = startAnimationSetup),
256 where = PluginDescriptor.WHERE_SESSIONSTART,
257 needsRestart = False,
258 fnc = sessionAnimationSetup),