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, ConfigSelectionNumber, getConfigListEntry
8 from Plugins.Plugin import PluginDescriptor
10 from enigma import setAnimation_current, setAnimation_speed
12 # default = slide to left
19 g_animation_paused = False
23 config.misc.window_animation_default = ConfigNumber(default=g_default["current"])
24 config.misc.window_animation_speed = ConfigSelectionNumber(1, g_max_speed, 1, default=g_default["speed"])
26 class AnimationSetupConfig(ConfigListScreen, Screen):
28 <screen position="center,center" size="600,140" title="Animation Settings">
29 <widget name="config" position="0,0" size="600,100" scrollbarMode="showOnDemand" />
31 <ePixmap pixmap="skin_default/buttons/red.png" position="0,100" size="140,40" alphatest="on" />
32 <ePixmap pixmap="skin_default/buttons/green.png" position="140,100" size="140,40" alphatest="on" />
33 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,100" size="140,40" alphatest="on" />
35 <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" />
36 <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" />
37 <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" />
41 def __init__(self, session):
42 self.session = session
45 Screen.__init__(self, session)
46 ConfigListScreen.__init__(self, self.entrylist)
48 self["actions"] = ActionMap(["OkCancelActions", "ColorActions",], {
50 "green" : self.keyGreen,
51 "yellow" : self.keyYellow,
53 "cancel" : self.keyRed,
55 self["key_red"] = StaticText(_("Cancel"))
56 self["key_green"] = StaticText(_("Save"))
57 self["key_yellow"] = StaticText(_("Default"))
60 self.onLayoutFinish.append(self.layoutFinished)
62 def layoutFinished(self):
63 self.setTitle(_('Animation Setup'))
66 config.misc.window_animation_speed.save()
67 setAnimation_speed(int(config.misc.window_animation_speed.value))
71 config.misc.window_animation_speed.cancel()
76 config.misc.window_animation_speed.value = g_default["speed"]
80 ConfigListScreen.keyLeft(self)
83 ConfigListScreen.keyRight(self)
85 def makeConfigList(self):
88 entrySpeed = getConfigListEntry(_("Animation Speed"), config.misc.window_animation_speed)
89 self.entrylist.append(entrySpeed)
90 self["config"].list = self.entrylist
91 self["config"].l.setList(self.entrylist)
94 class AnimationSetupScreen(Screen):
95 animationSetupItems = [
96 {"idx":0, "name":_("Disable Animations")},
97 {"idx":1, "name":_("Simple fade")},
98 {"idx":2, "name":_("Grow drop")},
99 {"idx":3, "name":_("Grow from left")},
100 {"idx":4, "name":_("Popup")},
101 {"idx":5, "name":_("Slide drop")},
102 {"idx":6, "name":_("Slide left to right")},
103 {"idx":7, "name":_("Slide top to bottom")},
104 {"idx":8, "name":_("Stripes")},
108 <screen name="AnimationSetup" position="center,center" size="580,400" title="Animation Setup">
109 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" zPosition="1" alphatest="on" />
110 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" zPosition="1" alphatest="on" />
111 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" zPosition="1" alphatest="on" />
112 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" zPosition="1" alphatest="on" />
114 <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" />
115 <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" />
116 <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" />
117 <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" />
119 <widget name="list" position="10,60" size="560,364" scrollbarMode="showOnDemand" />
120 <widget source="introduction" render="Label" position="0,370" size="560,40" zPosition="10" font="Regular;20" valign="center" backgroundColor="#25062748" transparent="1" />
123 def __init__(self, session):
125 self.skin = AnimationSetupScreen.skin
126 Screen.__init__(self, session)
128 self.animationList = []
130 self["introduction"] = StaticText(_("* current animation"))
131 self["key_red"] = StaticText(_("Cancel"))
132 self["key_green"] = StaticText(_("Save"))
133 self["key_yellow"] = StaticText(_("Setting"))
134 self["key_blue"] = StaticText(_("Preview"))
136 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
138 "cancel": self.keyclose,
141 "yellow": self.config,
145 self["list"] = MenuList(self.animationList)
147 self.onLayoutFinish.append(self.layoutFinished)
149 def layoutFinished(self):
151 for x in self.animationSetupItems:
152 key = x.get("idx", 0)
153 name = x.get("name", "??")
154 if key == config.misc.window_animation_default.value:
155 name = "* %s" % (name)
156 l.append( (name, key) )
158 self["list"].setList(l)
161 current = self["list"].getCurrent()
164 config.misc.window_animation_default.value = key
165 config.misc.window_animation_default.save()
166 setAnimation_current(key)
170 setAnimation_current(config.misc.window_animation_default.value)
171 setAnimation_speed(int(config.misc.window_animation_speed.value))
175 self.session.open(AnimationSetupConfig)
178 current = self["list"].getCurrent()
180 global g_animation_paused
181 tmp = g_animation_paused
182 g_animation_paused = False
184 setAnimation_current(current[1])
185 self.session.open(MessageBox, current[0], MessageBox.TYPE_INFO, timeout=3)
186 g_animation_paused = tmp
188 def checkAttrib(self, paused):
189 global g_animation_paused
190 if g_animation_paused is paused and self.skinAttributes is not None:
191 for (attr, value) in self.skinAttributes:
192 if attr == "animationPaused" and value in ("1", "on"):
196 def screen_show(self):
197 global g_animation_paused
198 if g_animation_paused:
199 setAnimation_current(0)
203 if checkAttrib(self, False):
204 g_animation_paused = True
206 def screen_doClose(self):
207 global g_animation_paused
208 if checkAttrib(self, True):
209 g_animation_paused = False
210 setAnimation_current(config.misc.window_animation_default.value)
213 def animationSetupMain(session, **kwargs):
214 session.open(AnimationSetupScreen)
216 def startAnimationSetup(menuid):
217 if menuid != "system":
220 return [( _("Animations"), animationSetupMain, "animation_setup", None)]
222 def sessionAnimationSetup(session, reason, **kwargs):
223 setAnimation_current(config.misc.window_animation_default.value)
224 setAnimation_speed(int(config.misc.window_animation_speed.value))
226 global g_orig_show, g_orig_doClose
227 if g_orig_show is None:
228 g_orig_show = Screen.show
229 if g_orig_doClose is None:
230 g_orig_doClose = Screen.doClose
231 Screen.show = screen_show
232 Screen.doClose = screen_doClose
234 def Plugins(**kwargs):
238 description = "Setup UI animations",
239 where = PluginDescriptor.WHERE_MENU,
240 needsRestart = False,
241 fnc = startAnimationSetup),
243 where = PluginDescriptor.WHERE_SESSIONSTART,
244 needsRestart = False,
245 fnc = sessionAnimationSetup),