- add fake "main menu"
authorFelix Domke <tmbinc@elitedvb.net>
Sat, 29 Jan 2005 05:22:00 +0000 (05:22 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sat, 29 Jan 2005 05:22:00 +0000 (05:22 +0000)
 - enable grc threading
 - disable some debug
 - dialog stacks

components.py
lib/gdi/font.cpp
lib/gdi/grc.cpp
lib/gui/ewindow.cpp
lib/gui/ewindowstyle.cpp
mytest.py
screens.py
skin.py

index 76423387d25242b633a35e8126d21e53e7944552..bd4c068f39854f57dc4f28fc304b7c2af21664d7 100644 (file)
@@ -60,7 +60,7 @@ class GUISkin:
                        # way of having refcounted objects. So it must be in python.)
                        #
                        # It could be possible that you're calling deleteGUIscreen trough a call of
-                       # a PSignal. For example, you could try to call session.close() in response
+                       # a PSignal. For example, you could try to call screen.doClose() in response
                        # to a Button::click. This will fail. (It wouldn't work anyway, as you would
                        # remove a dialog while running it. It never worked - enigma1 just set a 
                        # per-mainloop variable on eWidget::close() to leave the exec()...)
index f7c62209c3d186d5063482bb1cbffda5696b99e2..187512d505ea45ddf0f746640147a4d33740dc49 100644 (file)
@@ -60,12 +60,12 @@ static gLookup &getColor(const gPalette &pal, const gRGB &start, const gRGB &end
        if (i != colorcache.end())
                return i->second;
        gLookup &n=colorcache.insert(std::pair<fntColorCacheKey,gLookup>(key,gLookup())).first->second;
-       eDebug("[FONT] creating new font color cache entry %02x%02x%02x%02x .. %02x%02x%02x%02x", start.a, start.r, start.g, start.b,
-               end.a, end.r, end.g, end.b);
+//     eDebug("[FONT] creating new font color cache entry %02x%02x%02x%02x .. %02x%02x%02x%02x", start.a, start.r, start.g, start.b,
+//             end.a, end.r, end.g, end.b);
        n.build(16, pal, start, end);
-       for (int i=0; i<16; i++)
-               eDebugNoNewLine("%02x|%02x%02x%02x%02x ", (int)n.lookup[i], pal.data[n.lookup[i]].a, pal.data[n.lookup[i]].r, pal.data[n.lookup[i]].g, pal.data[n.lookup[i]].b);
-       eDebug("");
+//     for (int i=0; i<16; i++)
+//             eDebugNoNewLine("%02x|%02x%02x%02x%02x ", (int)n.lookup[i], pal.data[n.lookup[i]].a, pal.data[n.lookup[i]].r, pal.data[n.lookup[i]].g, pal.data[n.lookup[i]].b);
+//     eDebug("");
        return n;
 }
 
index 137e92dc62dfa33cfddf981a7f07264593404d5f..a63aef9278ea2770ad5e0d287d7bccf40506fca1 100644 (file)
@@ -1,5 +1,5 @@
 // for debugging use:
- #define SYNC_PAINT
+// #define SYNC_PAINT
 #include <unistd.h>
 #ifndef SYNC_PAINT
 #include <pthread.h>
index 630a8aa364c0c8141da2472ff50263536273b1fe..1114d2587fc85230976aae3cfd709ddfec17e9bd 100644 (file)
@@ -37,7 +37,7 @@ int eWindow::event(int event, void *data, void *data2)
                if (!getStyle(style))
                {
                        const eSize &new_size = *static_cast<eSize*>(data);
-                       eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
+//                     eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
                        style->handleNewSize(this, new_size);
                }
                break;
index 64adfb581d88149e3e840278caa53e64cedfddc2..a5ace37ae8b5413b85b03f0af5a3288cb6ab5de2 100644 (file)
@@ -24,7 +24,7 @@ eWindowStyleSimple::eWindowStyleSimple()
 
 void eWindowStyleSimple::handleNewSize(eWindow *wnd, const eSize &size)
 {
-       eDebug("handle new size: %d x %d", size.width(), size.height());
+//     eDebug("handle new size: %d x %d", size.width(), size.height());
        
        eWidget *child = wnd->child();
        
index edaf24a5e79111f8dfd2d821e3c8a9102d2d5fda..e257f11a160c5a84e37599f10c808430080ddcda 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -34,15 +34,6 @@ components = {}
 # do global
 screens["global"](components)
 
-# test our screens
-components["$001"] = screens["testDialog"]()
-
-#print "*** classes:"
-#dump(screens)
-#
-#print "*** instances:"
-#dump(components)
-
 # display
 
 class OutputDevice:
@@ -68,6 +59,8 @@ class Session:
                self.delayTimer.timeout.get().append(self.processDelay)
                
                self.currentDialog = None
+               
+               self.dialogStack = [ ]
        
        def processDelay(self):
                self.currentDialog.doClose()
@@ -77,9 +70,15 @@ class Session:
                del self.currentDialog
                del self.currentWindow
                
-               self.open(screens["testDialog"]())
-
+               if len(self.dialogStack):
+                       (self.currentDialog, self.currentWindow) = self.dialogStack.pop()
+                       self.currentWindow.show()
+       
        def open(self, screen):
+               if self.currentDialog:
+                       self.dialogStack.append((self.currentDialog, self.currentWindow))
+                       self.currentWindow.hide()
+               
                self.currentDialog = screen
                screen.session = self
                
@@ -114,8 +113,8 @@ def runScreenTest():
        session = Session()
        session.desktop = getDesktop()
        
-       session.open(screens["clockDisplay"](components["clock"]))
-#      session.open(screens["testDialog"]())
+#      session.open(screens["clockDisplay"](components["clock"]))
+       session.open(screens["testDialog"]())
 
        # simple reason for this helper function: we want to call the currently
        # active "okbutton", even when we changed the dialog
index a04772db3620e9d9a1bee435dc5c66904c9f0c1f..3dbcb4aac03c34bdf4e36fcfc163461e89c9e0bf 100644 (file)
@@ -22,20 +22,22 @@ class testDialog(Screen):
                selection[1]()
        
        def goMain(self):
-#              self.close(0)
-               self["title"].setText("you selected the main menu!");
+               self.session.open(screens["mainMenu"]())
                
        def goEmu(self):
 #              self.close(1)
-               self["title"].setText("EMUs ARE ILLEGAL AND NOT SUPPORTED!");
+               self["title"].setText("EMUs ARE ILLEGAL AND NOT SUPPORTED!")
        
        def goTimeshift(self):
 #              self.close(2)
-               self["title"].setText("JUST PRESS THE YELLOW BUTTON!");
+               self["title"].setText("JUST PRESS THE YELLOW BUTTON!")
        
        def goHDTV(self):
 #              self.close(3)
-               self["title"].setText("HDTV GREEN FLASHES: ENABLED");
+               self["title"].setText("HDTV GREEN FLASHES: ENABLED")
+       
+       def goClock(self):
+               self.session.open(screens["clockDisplay"](Clock()))
 
        def __init__(self):
                GUISkin.__init__(self)
@@ -48,23 +50,22 @@ class testDialog(Screen):
                                ("MAIN MENU", self.goMain), 
                                ("EMU SETUP", self.goEmu),
                                ("TIMESHIFT SETUP", self.goTimeshift),
-                               ("HDTV PIP CONFIG", self.goHDTV)
+                               ("HDTV PIP CONFIG", self.goHDTV),
+                               ("wie spaet ists?!", self.goClock)
                        ])
 
-
-class MainMenu(Screen):
+class mainMenu(Screen):
        def __init__(self):
                GUISkin.__init__(self)
                
-               self["ok"] = Button("ok")
-               self["ok"].onClick = [ self.close ]
+               self["title"] = Header("this is the\nMAIN MENU !!!");
+               self["okbutton"] = Button("ok")
+               self["okbutton"].onClick = [ self.close ]
 
        
 # a clock display dialog
 class clockDisplay(Screen):
        def okbutton(self):
-               print "clockDisplay close"
-               
                self.session.close()
        
        def __init__(self, clock):
@@ -75,9 +76,10 @@ class clockDisplay(Screen):
                self["okbutton"] = b
                self["title"] = Header("clock dialog: here you see the current uhrzeit!")
 
-# defined screens
+# defined screens (evtl. kann man sich das sparen, ich seh den sinn gerade nicht mehr)
 screens = {
        "global": doGlobal,
        "testDialog": testDialog,
-       "clockDisplay": clockDisplay }
+       "clockDisplay": clockDisplay ,
+       "mainMenu": mainMenu }
 
diff --git a/skin.py b/skin.py
index 2996edb02e4cf8f467533f9f244c9b76ba3ae620..9fbdfeb4fa34f3446fad55c2340b98a76aacace1 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -14,15 +14,19 @@ dom = xml.dom.minidom.parseString(
        """
        <skin>
                <screen name="testDialog">
-                       <widget name="okbutton" position="10,120" size="280,40" />
+                       <widget name="okbutton" position="10,190" size="280,50" />
                        <widget name="title" position="10,10" size="280,20" />
-                       <widget name="menu" position="10,30" size="280,90" />
+                       <widget name="menu" position="10,30" size="280,140" />
                </screen>
                <screen name="clockDisplay" position="300,100" size="300,300">
                        <widget name="okbutton" position="10,10" size="280,40" />
                        <widget name="title" position="10,120" size="280,50" />
                        <widget name="theClock" position="10,60" size="280,50" />
                </screen>
+               <screen name="mainMenu" position="300,100" size="300,300">
+                       <widget name="title" position="10,10" size="280,80" />
+                       <widget name="okbutton" position="10,190" size="280,50" />
+               </screen>
        </skin>
 """)
 
@@ -61,17 +65,19 @@ def applyGUIskin(screen, skin, name):
                if x.getAttribute('name') == name:
                        myscreen = x
        
-       assert myscreen != None, "no skin for screen " + name + " found!"
-       
-       print "ok, found screen.."
+       assert myscreen != None, "no skin for screen '" + name + "' found!"
        
        # now walk all widgets
        for widget in myscreen.getElementsByTagName("widget"):
-               name = widget.getAttribute('name')
-               if name == None:
+               wname = widget.getAttribute('name')
+               if wname == None:
                        print "widget has no name!"
                        continue
                
                # get corresponding gui object
-               guiObject = screen.data[name]["instance"]
+               try:
+                       guiObject = screen.data[wname]["instance"]
+               except:
+                       raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
+               
                applyAttributes(guiObject, widget)