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
11 from Components.SystemInfo import SystemInfo
13 # default = slide to left
16 "speed" : SystemInfo.get("DefaultAniSpeed", 20),
21 g_animation_paused = False
25 config.misc.window_animation_default = ConfigNumber(default=g_default["current"])
26 config.misc.window_animation_speed = ConfigSelectionNumber(1, g_max_speed, 1, default=g_default["speed"])
27 config.misc.listbox_animation_default = ConfigSelection(default = g_default["listbox"], choices = [ ("0", _("Disable")), ("1", _("Enable")), ("2", _("Same behavior as current animation")) ])
29 class AnimationSetupConfig(ConfigListScreen, Screen):
31 <screen position="center,center" size="600,140" title="Animation Settings">
32 <widget name="config" position="0,0" size="600,100" scrollbarMode="showOnDemand" />
34 <ePixmap pixmap="skin_default/buttons/red.png" position="0,100" size="140,40" alphatest="on" />
35 <ePixmap pixmap="skin_default/buttons/green.png" position="140,100" size="140,40" alphatest="on" />
36 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,100" size="140,40" alphatest="on" />
38 <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" />
39 <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" />
40 <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" />
44 def __init__(self, session):
45 self.session = session
48 Screen.__init__(self, session)
49 ConfigListScreen.__init__(self, self.entrylist)
51 self["actions"] = ActionMap(["OkCancelActions", "ColorActions",], {
53 "green" : self.keyGreen,
54 "yellow" : self.keyYellow,
56 "cancel" : self.keyRed,
58 self["key_red"] = StaticText(_("Cancel"))
59 self["key_green"] = StaticText(_("Save"))
60 self["key_yellow"] = StaticText(_("Default"))
63 self.onLayoutFinish.append(self.layoutFinished)
65 def layoutFinished(self):
66 self.setTitle(_('Animation Setup'))
69 config.misc.window_animation_speed.save()
70 setAnimation_speed(int(config.misc.window_animation_speed.value))
71 config.misc.listbox_animation_default.save()
72 setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
76 config.misc.window_animation_speed.cancel()
77 config.misc.listbox_animation_default.cancel()
83 config.misc.window_animation_speed.value = g_default["speed"]
84 config.misc.listbox_animation_default.value = g_default["listbox"]
88 ConfigListScreen.keyLeft(self)
91 ConfigListScreen.keyRight(self)
93 def makeConfigList(self):
96 entrySpeed = getConfigListEntry(_("Animation Speed"), config.misc.window_animation_speed)
97 self.entrylist.append(entrySpeed)
98 entryMoveSelection = getConfigListEntry(_("Enable Focus Animation"), config.misc.listbox_animation_default)
99 self.entrylist.append(entryMoveSelection)
101 self["config"].list = self.entrylist
102 self["config"].l.setList(self.entrylist)
105 class AnimationSetupScreen(Screen):
106 animationSetupItems = [
107 {"idx":0, "name":_("Disable Animations")},
108 {"idx":1, "name":_("Simple fade")},
109 {"idx":2, "name":_("Grow drop")},
110 {"idx":3, "name":_("Grow from left")},
111 {"idx":4, "name":_("Popup")},
112 {"idx":5, "name":_("Slide drop")},
113 {"idx":6, "name":_("Slide left to right")},
114 {"idx":7, "name":_("Slide top to bottom")},
115 {"idx":8, "name":_("Stripes")},
119 <screen name="AnimationSetup" position="center,center" size="580,400" title="Animation Setup">
120 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" zPosition="1" alphatest="on" />
121 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" zPosition="1" alphatest="on" />
122 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" zPosition="1" alphatest="on" />
123 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" zPosition="1" alphatest="on" />
125 <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" />
126 <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" />
127 <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" />
128 <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" />
130 <widget name="list" position="10,60" size="560,364" scrollbarMode="showOnDemand" />
131 <widget source="introduction" render="Label" position="0,370" size="560,40" zPosition="10" font="Regular;20" valign="center" backgroundColor="#25062748" transparent="1" />
134 def __init__(self, session):
136 self.skin = AnimationSetupScreen.skin
137 Screen.__init__(self, session)
139 self.animationList = []
141 self["introduction"] = StaticText(_("* current animation"))
142 self["key_red"] = StaticText(_("Cancel"))
143 self["key_green"] = StaticText(_("Save"))
144 self["key_yellow"] = StaticText(_("Setting"))
145 self["key_blue"] = StaticText(_("Preview"))
147 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
149 "cancel": self.keyclose,
152 "yellow": self.config,
156 self["list"] = MenuList(self.animationList)
158 self.onLayoutFinish.append(self.layoutFinished)
160 def layoutFinished(self):
162 for x in self.animationSetupItems:
163 key = x.get("idx", 0)
164 name = x.get("name", "??")
165 if key == config.misc.window_animation_default.value:
166 name = "* %s" % (name)
167 l.append( (name, key) )
169 self["list"].setList(l)
172 current = self["list"].getCurrent()
175 config.misc.window_animation_default.value = key
176 config.misc.window_animation_default.save()
177 setAnimation_current(key)
178 setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
182 setAnimation_current(config.misc.window_animation_default.value)
183 setAnimation_speed(int(config.misc.window_animation_speed.value))
184 setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
188 self.session.open(AnimationSetupConfig)
191 current = self["list"].getCurrent()
193 global g_animation_paused
194 tmp = g_animation_paused
195 g_animation_paused = False
197 setAnimation_current(current[1])
198 self.session.open(MessageBox, current[0], MessageBox.TYPE_INFO, timeout=3)
199 g_animation_paused = tmp
201 def checkAttrib(self, paused):
202 global g_animation_paused
203 if g_animation_paused is paused and self.skinAttributes is not None:
204 for (attr, value) in self.skinAttributes:
205 if attr == "animationPaused" and value in ("1", "on"):
209 def screen_show(self):
210 global g_animation_paused
211 if g_animation_paused:
212 setAnimation_current(0)
216 if checkAttrib(self, False):
217 g_animation_paused = True
219 def screen_doClose(self):
220 global g_animation_paused
221 if checkAttrib(self, True):
222 g_animation_paused = False
223 setAnimation_current(config.misc.window_animation_default.value)
226 def animationSetupMain(session, **kwargs):
227 session.open(AnimationSetupScreen)
229 def startAnimationSetup(menuid):
230 if menuid != "system":
233 return [( _("Animations"), animationSetupMain, "animation_setup", None)]
235 def sessionAnimationSetup(session, reason, **kwargs):
236 setAnimation_current(config.misc.window_animation_default.value)
237 setAnimation_speed(int(config.misc.window_animation_speed.value))
238 setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
240 global g_orig_show, g_orig_doClose
241 if g_orig_show is None:
242 g_orig_show = Screen.show
243 if g_orig_doClose is None:
244 g_orig_doClose = Screen.doClose
245 Screen.show = screen_show
246 Screen.doClose = screen_doClose
248 def Plugins(**kwargs):
252 description = "Setup UI animations",
253 where = PluginDescriptor.WHERE_MENU,
254 needsRestart = False,
255 fnc = startAnimationSetup),
257 where = PluginDescriptor.WHERE_SESSIONSTART,
258 needsRestart = False,
259 fnc = sessionAnimationSetup),