From 9ecc8d37f8d4078521a47faa8168534b6047254f Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Wed, 31 Aug 2022 19:22:30 -0500 Subject: [PATCH] Minimized windows are now always drawn behind open windows. --- roo-e/src/gui/wmwindow.c | 74 +++++++++++++++++++++++++--------------- roo-e/src/gui/wmwindow.h | 2 ++ roo-e/src/main.c | 4 +-- 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/roo-e/src/gui/wmwindow.c b/roo-e/src/gui/wmwindow.c index 74866b4..220369c 100644 --- a/roo-e/src/gui/wmwindow.c +++ b/roo-e/src/gui/wmwindow.c @@ -511,37 +511,47 @@ static void windowPaint(struct WidgetS *widget, ...) { int16_t xc; int16_t yc; WindowT *w = (WindowT *)widget; + va_list args; + uint8_t mode; - // Does the window itself need redrawn? - if (widgetDirtyGet(widget)) { - widgetDirtySet(widget, 0); - x = 1; // This is a flag for later that we need to update the cached surface. - } + // What paint mode are we in? + va_start(args, widget); + mode = va_arg(args, int); + va_end(args); - // Did a widget or the window need redrawn? - if (x || widgetChildrenDirty(widget)) windowCache(w, x); - - // Are we minimized? - if (w->flags & WIN_IS_ICON) { - // Draw iconized version of contents. There are too many counters here but it's the only way it worked reliably. - yi = (surfaceHeightGet(w->scroll->area) - 1) / ICON_SIZE; - xi = (surfaceWidthGet(w->scroll->area) - 1) / ICON_SIZE; - py = videoDisplayHeightGet() - ICON_SIZE; - y = 0; - x = 0; - for (yc=0; ycscroll->area, x, y)); + if (mode == WINDOW_PAINT_ICONS) { + // Are we minimized? + if (w->flags & WIN_IS_ICON) { + // Draw iconized version of contents. There are too many counters here but it's the only way it worked reliably. + yi = (surfaceHeightGet(w->scroll->area) - 1) / ICON_SIZE; + xi = (surfaceWidthGet(w->scroll->area) - 1) / ICON_SIZE; + py = videoDisplayHeightGet() - ICON_SIZE; + y = 0; + x = 0; + for (yc=0; ycscroll->area, x, y)); + } + py++; } - py++; + _iconCount++; + } + } else { // WINDOW_PAINT_ICONS + // Are we not minimized? + if (!(w->flags & WIN_IS_ICON)) { + // Does the window chrome itself need redrawn? + if (widgetDirtyGet(widget)) { + widgetDirtySet(widget, 0); + x = 1; // This is a flag for later that we need to update the cached surface. + } + // Did a widget or the window chrome need redrawn? + if (x || widgetChildrenDirty(widget)) windowCache(w, x); + // By now we have a valid cached window. Blit it. + surfaceBlit(w->base.r.x, w->base.r.y, 0, 0, w->base.r.w, w->base.r.h, w->cached); } - _iconCount++; - } else { - // By now we have a valid cached window. Blit it. - surfaceBlit(w->base.r.x, w->base.r.y, 0, 0, w->base.r.w, w->base.r.h, w->cached); } } @@ -647,12 +657,20 @@ void wmUpdate(EventT *event) { // Mouse is always the default pointer unless something changes it for this frame. guiMousePointerSet(MOUSE_POINTER); + // Paint all minimized windows. + surfaceSet(__guiBackBuffer); + _iconCount = 0; + for (i=0; ireg->paint(widget, 0); + } + // Paint all windows. _iconCount = 0; for (i=0; ireg->paint(widget); + widget->reg->paint(widget, 1); } // Get top window. diff --git a/roo-e/src/gui/wmwindow.h b/roo-e/src/gui/wmwindow.h index 30f62bc..3fddcb1 100644 --- a/roo-e/src/gui/wmwindow.h +++ b/roo-e/src/gui/wmwindow.h @@ -35,6 +35,8 @@ #define ICON_SIZE 32 #define GADGET_SIZE 20 +#define WINDOW_PAINT_ICONS 0 +#define WINDOW_PAINT_NORMAL 1 #define WIN_NONE 0 #define WIN_CLOSE 1 diff --git a/roo-e/src/main.c b/roo-e/src/main.c index 9e1af3f..1a1005e 100644 --- a/roo-e/src/main.c +++ b/roo-e/src/main.c @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) { if (guiStartup(800, 600, 16) == SUCCESS) { - for (i=1; i<2; i++) { + for (i=1; i<4; i++) { sprintf(title, "Testing %d", i); w = windowCreate(i * 50, i * 50, 600, 400, title, WIN_STANDARD, 640, 480); @@ -95,7 +95,6 @@ int main(int argc, char *argv[]) { r = radioCreate("Radio C", 1, 0); widgetAdd(W(w), 220, 140, W(r)); - /* _v = vscrollCreate(100, clickHandler, NULL); vscrollRangeSet(_v, 0, 640); widgetAdd(W(w), 200, 5, W(_v)); @@ -106,7 +105,6 @@ int main(int argc, char *argv[]) { s = scrollableCreate(300, 200, 648, 480, SCROLLABLE_STANDARD); widgetAdd(W(w), 20, 170, W(s)); - */ } guiRun(); guiShutdown();