From 6b7b7977a92c9a092763bf699cba85347f9f2ec6 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Sat, 29 Jan 2005 05:22:00 +0000 Subject: [PATCH] - add fake "main menu" - enable grc threading - disable some debug - dialog stacks --- components.py | 2 +- lib/gdi/font.cpp | 10 +++++----- lib/gdi/grc.cpp | 2 +- lib/gui/ewindow.cpp | 2 +- lib/gui/ewindowstyle.cpp | 2 +- mytest.py | 25 ++++++++++++------------- screens.py | 30 ++++++++++++++++-------------- skin.py | 22 ++++++++++++++-------- 8 files changed, 51 insertions(+), 44 deletions(-) diff --git a/components.py b/components.py index 76423387..bd4c068f 100644 --- a/components.py +++ b/components.py @@ -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()...) diff --git a/lib/gdi/font.cpp b/lib/gdi/font.cpp index f7c62209..187512d5 100644 --- a/lib/gdi/font.cpp +++ b/lib/gdi/font.cpp @@ -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(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; } diff --git a/lib/gdi/grc.cpp b/lib/gdi/grc.cpp index 137e92dc..a63aef92 100644 --- a/lib/gdi/grc.cpp +++ b/lib/gdi/grc.cpp @@ -1,5 +1,5 @@ // for debugging use: - #define SYNC_PAINT +// #define SYNC_PAINT #include #ifndef SYNC_PAINT #include diff --git a/lib/gui/ewindow.cpp b/lib/gui/ewindow.cpp index 630a8aa3..1114d258 100644 --- a/lib/gui/ewindow.cpp +++ b/lib/gui/ewindow.cpp @@ -37,7 +37,7 @@ int eWindow::event(int event, void *data, void *data2) if (!getStyle(style)) { const eSize &new_size = *static_cast(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; diff --git a/lib/gui/ewindowstyle.cpp b/lib/gui/ewindowstyle.cpp index 64adfb58..a5ace37a 100644 --- a/lib/gui/ewindowstyle.cpp +++ b/lib/gui/ewindowstyle.cpp @@ -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(); diff --git a/mytest.py b/mytest.py index edaf24a5..e257f11a 100644 --- 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 diff --git a/screens.py b/screens.py index a04772db..3dbcb4aa 100644 --- a/screens.py +++ b/screens.py @@ -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 2996edb0..9fbdfeb4 100644 --- a/skin.py +++ b/skin.py @@ -14,15 +14,19 @@ dom = xml.dom.minidom.parseString( """ - + - + + + + + """) @@ -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) -- 2.30.2