Support focus animation for listbox
authorsmlee <smlee@dev3>
Thu, 8 Dec 2016 07:09:35 +0000 (16:09 +0900)
committersmlee <smlee@dev3>
Mon, 12 Dec 2016 01:09:53 +0000 (10:09 +0900)
lib/gdi/gfbdc.cpp
lib/gdi/grc.cpp
lib/gdi/grc.h
lib/gui/elistbox.cpp
lib/gui/elistbox.h
lib/python/Plugins/SystemPlugins/AnimationSetup/plugin.py
lib/python/enigma_python.i
lib/service/listboxservice.cpp
main/enigma.cpp

index d3cc55f..eda5bf2 100644 (file)
@@ -133,6 +133,8 @@ void gFBDC::exec(const gOpcode *o)
                        gles_do_animation();
                else
                        fb->blit();
+
+               gles_flush();
 #else
                fb->blit();
 #endif
@@ -143,6 +145,7 @@ void gFBDC::exec(const gOpcode *o)
                gles_set_buffer((unsigned int *)surface.data);
                gles_set_animation(1, o->parm.setShowHideInfo->point.x(), o->parm.setShowHideInfo->point.y(), o->parm.setShowHideInfo->size.width(), o->parm.setShowHideInfo->size.height());
 #endif
+               delete o->parm.setShowHideInfo;
                break;
        }
        case gOpcode::sendHide:
@@ -151,12 +154,27 @@ void gFBDC::exec(const gOpcode *o)
                gles_set_buffer((unsigned int *)surface.data);
                gles_set_animation(0, o->parm.setShowHideInfo->point.x(), o->parm.setShowHideInfo->point.y(), o->parm.setShowHideInfo->size.width(), o->parm.setShowHideInfo->size.height());
 #endif
+               delete o->parm.setShowHideInfo;
                break;
        }
 #ifdef USE_LIBVUGLES2
+       case gOpcode::sendShowItem:
+       {
+               gles_set_buffer((unsigned int *)surface.data);
+               gles_set_animation_listbox(o->parm.setShowItemInfo->dir, o->parm.setShowItemInfo->point.x(), o->parm.setShowItemInfo->point.y(), o->parm.setShowItemInfo->size.width(), o->parm.setShowItemInfo->size.height());
+               delete o->parm.setShowItemInfo;
+               break;
+       }
+       case gOpcode::setFlush:
+       {
+               gles_set_flush(o->parm.setFlush->enable);
+               delete o->parm.setFlush;
+               break;
+       }
        case gOpcode::setView:
        {
                gles_viewport(o->parm.setViewInfo->size.width(), o->parm.setViewInfo->size.height(), fb->Stride());
+               delete o->parm.setViewInfo;
                break;
        }
 #endif
index ffb4c30..643e144 100644 (file)
@@ -636,6 +636,32 @@ void gPainter::sendHide(ePoint point, eSize size)
 }
 
 #ifdef USE_LIBVUGLES2
+void gPainter::sendShowItem(long dir, ePoint point, eSize size)
+{
+       if ( m_dc->islocked() )
+               return;
+       gOpcode o;
+       o.opcode=gOpcode::sendShowItem;
+       o.dc = m_dc.grabRef();
+       o.parm.setShowItemInfo = new gOpcode::para::psetShowItemInfo;
+       o.parm.setShowItemInfo->dir = dir;
+       o.parm.setShowItemInfo->point = point;
+       o.parm.setShowItemInfo->size = size;
+       m_rc->submit(o);
+}
+
+void gPainter::setFlush(bool val)
+{
+       if ( m_dc->islocked() )
+               return;
+       gOpcode o;
+       o.opcode=gOpcode::setFlush;
+       o.dc = m_dc.grabRef();
+       o.parm.setFlush = new gOpcode::para::psetFlush;
+       o.parm.setFlush->enable = val;
+       m_rc->submit(o);
+}
+
 void gPainter::setView(eSize size)
 {
        if ( m_dc->islocked() )
@@ -847,6 +873,10 @@ void gDC::exec(const gOpcode *o)
        case gOpcode::sendHide:
                break;
 #ifdef USE_LIBVUGLES2
+       case gOpcode::sendShowItem:
+               break;
+       case gOpcode::setFlush:
+               break;
        case gOpcode::setView:
                break;
 #endif
index bcd2cf4..e91e7e8 100644 (file)
@@ -67,6 +67,8 @@ struct gOpcode
                sendShow,
                sendHide,
 #ifdef USE_LIBVUGLES2
+               sendShowItem,
+               setFlush,
                setView,
 #endif
        } opcode;
@@ -155,7 +157,20 @@ struct gOpcode
                        ePoint point;
                        eSize size;
                } *setShowHideInfo;
+
 #ifdef USE_LIBVUGLES2
+               struct psetShowItemInfo
+               {
+                       long dir;
+                       ePoint point;
+                       eSize size;
+               } *setShowItemInfo;
+
+               struct psetFlush
+               {
+                       bool enable;
+               } *setFlush;
+
                struct psetViewInfo
                {
                        eSize size;
@@ -287,6 +302,8 @@ public:
        void sendShow(ePoint point, eSize size);
        void sendHide(ePoint point, eSize size);
 #ifdef USE_LIBVUGLES2
+       void sendShowItem(long dir, ePoint point, eSize size);
+       void setFlush(bool val);
        void setView(eSize size);
 #endif
 };
index a73cfdb..f241e6f 100644 (file)
@@ -2,6 +2,9 @@
 #include <lib/gui/elistboxcontent.h>
 #include <lib/gui/eslider.h>
 #include <lib/actions/action.h>
+#ifdef USE_LIBVUGLES2
+#include "vuplus_gles.h"
+#endif
 
 eListbox::eListbox(eWidget *parent) :
        eWidget(parent), m_scrollbar_mode(showNever), m_prev_scrollbar_page(-1),
@@ -105,6 +108,9 @@ void eListbox::moveSelection(long dir)
        int oldtop = m_top;
        int oldsel = m_selected;
                /* first, move cursor */
+#ifdef USE_LIBVUGLES2
+       m_dir = dir;
+#endif
        switch (dir)
        {
        case moveUp:
@@ -323,6 +329,14 @@ int eListbox::event(int event, void *data, void *data2)
 
                        if (!entry_clip_rect.empty())
                                m_content->paint(painter, *style, ePoint(0, y), m_selected == m_content->cursorGet() && m_content->size() && m_selection_enabled);
+#ifdef USE_LIBVUGLES2
+                       if (m_selected == m_content->cursorGet() && m_content->size() && m_selection_enabled) {
+                               ePoint pos = getAbsolutePosition();
+                               painter.sendShowItem(m_dir, ePoint(pos.x(), pos.y() + y), eSize(m_scrollbar && m_scrollbar->isVisible() ? size().width() - m_scrollbar->size().width() : size().width(), m_itemheight));
+                               gles_set_animation_listbox_current(pos.x(), pos.y() + y, m_scrollbar && m_scrollbar->isVisible() ? size().width() - m_scrollbar->size().width() : size().width(), m_itemheight);
+                               m_dir = justCheck;
+                       }
+#endif
 
                                /* (we could clip with entry_clip_rect, but 
                                   this shouldn't change the behavior of any
index 7334e48..17fce5c 100644 (file)
@@ -160,6 +160,9 @@ private:
        ePtr<iListboxContent> m_content;
        eSlider *m_scrollbar;
        eListboxStyle m_style;
+#ifdef USE_LIBVUGLES2
+       long m_dir;
+#endif
 #endif
 };
 
index f289b34..253bbf8 100644 (file)
@@ -4,15 +4,16 @@ from Components.ActionMap import ActionMap
 from Components.ConfigList import ConfigListScreen
 from Components.MenuList import MenuList
 from Components.Sources.StaticText import StaticText
-from Components.config import config, ConfigNumber, ConfigSelectionNumber, getConfigListEntry
+from Components.config import config, ConfigNumber, ConfigSelection, ConfigSelectionNumber, getConfigListEntry
 from Plugins.Plugin import PluginDescriptor
 
-from enigma import setAnimation_current, setAnimation_speed
+from enigma import setAnimation_current, setAnimation_speed, setAnimation_current_listbox
 
 # default = slide to left
 g_default = {
-        "current": 6,
-        "speed"  : 20,
+       "current": 6,
+       "speed"  : 20,
+       "listbox": "2",
 }
 g_max_speed = 30
 
@@ -22,6 +23,7 @@ g_orig_doClose = None
 
 config.misc.window_animation_default = ConfigNumber(default=g_default["current"])
 config.misc.window_animation_speed = ConfigSelectionNumber(1, g_max_speed, 1, default=g_default["speed"])
+config.misc.listbox_animation_default = ConfigSelection(default = g_default["listbox"], choices = [ ("0", _("Disable")), ("1", _("Enable")), ("2", _("Same behavior as current animation")) ])
 
 class AnimationSetupConfig(ConfigListScreen, Screen):
        skin=   """
@@ -64,16 +66,21 @@ class AnimationSetupConfig(ConfigListScreen, Screen):
 
        def keyGreen(self):
                config.misc.window_animation_speed.save()
-                setAnimation_speed(int(config.misc.window_animation_speed.value))
+               setAnimation_speed(int(config.misc.window_animation_speed.value))
+               config.misc.listbox_animation_default.save()
+               setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
                self.close()
 
        def keyRed(self):
                config.misc.window_animation_speed.cancel()
+               config.misc.listbox_animation_default.cancel()
                self.close()
 
        def keyYellow(self):
-                global g_default
-                config.misc.window_animation_speed.value = g_default["speed"]
+               global g_default
+
+               config.misc.window_animation_speed.value = g_default["speed"]
+               config.misc.listbox_animation_default.value = g_default["listbox"]
                self.makeConfigList()
 
        def keyLeft(self):
@@ -87,6 +94,9 @@ class AnimationSetupConfig(ConfigListScreen, Screen):
 
                entrySpeed = getConfigListEntry(_("Animation Speed"), config.misc.window_animation_speed)
                self.entrylist.append(entrySpeed)
+               entryMoveSelection = getConfigListEntry(_("Enable Focus Animation"), config.misc.listbox_animation_default)
+               self.entrylist.append(entryMoveSelection)
+
                self["config"].list = self.entrylist
                self["config"].l.setList(self.entrylist)
 
@@ -117,7 +127,7 @@ class AnimationSetupScreen(Screen):
                        <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" />
 
                        <widget name="list" position="10,60" size="560,364" scrollbarMode="showOnDemand" />
-                       <widget source="introduction" render="Label" position="0,370" size="560,40" zPosition="10" font="Regular;20" valign="center" backgroundColor="#25062748" transparent="1" />
+                       <widget source="introduction" render="Label" position="0,370" size="560,40" zPosition="10" font="Regular;20" valign="center" backgroundColor="#25062748" transparent="1" />
                </screen>"""
 
        def __init__(self, session):
@@ -164,15 +174,17 @@ class AnimationSetupScreen(Screen):
                        config.misc.window_animation_default.value = key
                        config.misc.window_animation_default.save()
                        setAnimation_current(key)
+                       setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
                self.close()
 
-        def keyclose(self):
+       def keyclose(self):
                setAnimation_current(config.misc.window_animation_default.value)
-                setAnimation_speed(int(config.misc.window_animation_speed.value))
+               setAnimation_speed(int(config.misc.window_animation_speed.value))
+               setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
                self.close()
 
        def config(self):
-                self.session.open(AnimationSetupConfig)
+               self.session.open(AnimationSetupConfig)
 
        def preview(self):
                current = self["list"].getCurrent()
@@ -222,6 +234,7 @@ def startAnimationSetup(menuid):
 def sessionAnimationSetup(session, reason, **kwargs):
        setAnimation_current(config.misc.window_animation_default.value)
        setAnimation_speed(int(config.misc.window_animation_speed.value))
+       setAnimation_current_listbox(int(config.misc.listbox_animation_default.value))
 
        global g_orig_show, g_orig_doClose
        if g_orig_show is None:
index e9a8161..61af4e9 100755 (executable)
@@ -379,6 +379,7 @@ extern const char *getEnigmaVersionString();
 extern void dump_malloc_stats(void);
 extern void setAnimation_current(int a);
 extern void setAnimation_speed(int speed);
+extern void setAnimation_current_listbox(int a);
 %}
 
 extern void addFont(const char *filename, const char *alias, int scale_factor, int is_replacement);
@@ -390,3 +391,4 @@ extern const char *getEnigmaVersionString();
 extern void dump_malloc_stats(void);
 extern void setAnimation_current(int a);
 extern void setAnimation_speed(int speed);
+extern void setAnimation_current_listbox(int a);
index 7944503..074b8cd 100644 (file)
@@ -627,6 +627,9 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
                                {
                                        if (service_info)
                                                service_info->getName(*m_cursor, text);
+#ifdef USE_LIBVUGLES2
+                                       painter.setFlush(text == "<n/a>");
+#endif
                                        break;
                                }
                                case celServiceInfo:
index 6ea4a64..b9cdf34 100644 (file)
@@ -346,7 +346,13 @@ void setAnimation_speed(int speed)
 {
        gles_set_animation_speed(speed);
 }
+
+void setAnimation_current_listbox(int a)
+{
+       gles_set_animation_listbox_func(a);
+}
 #else
 void setAnimation_current(int a) {}
 void setAnimation_speed(int speed) {}
+void setAnimation_current_listbox(int a) {}
 #endif