Minimized windows are now always drawn behind open windows.

This commit is contained in:
Scott Duensing 2022-08-31 19:22:30 -05:00
parent 481481a952
commit 9ecc8d37f8
3 changed files with 49 additions and 31 deletions

View file

@ -511,16 +511,15 @@ static void windowPaint(struct WidgetS *widget, ...) {
int16_t xc; int16_t xc;
int16_t yc; int16_t yc;
WindowT *w = (WindowT *)widget; WindowT *w = (WindowT *)widget;
va_list args;
uint8_t mode;
// Does the window itself need redrawn? // What paint mode are we in?
if (widgetDirtyGet(widget)) { va_start(args, widget);
widgetDirtySet(widget, 0); mode = va_arg(args, int);
x = 1; // This is a flag for later that we need to update the cached surface. va_end(args);
}
// Did a widget or the window need redrawn?
if (x || widgetChildrenDirty(widget)) windowCache(w, x);
if (mode == WINDOW_PAINT_ICONS) {
// Are we minimized? // Are we minimized?
if (w->flags & WIN_IS_ICON) { 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. // Draw iconized version of contents. There are too many counters here but it's the only way it worked reliably.
@ -539,11 +538,22 @@ static void windowPaint(struct WidgetS *widget, ...) {
py++; py++;
} }
_iconCount++; _iconCount++;
} else { }
} 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. // 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); surfaceBlit(w->base.r.x, w->base.r.y, 0, 0, w->base.r.w, w->base.r.h, w->cached);
} }
} }
}
RegisterT *windowRegister(uint8_t magic) { RegisterT *windowRegister(uint8_t magic) {
@ -647,12 +657,20 @@ void wmUpdate(EventT *event) {
// Mouse is always the default pointer unless something changes it for this frame. // Mouse is always the default pointer unless something changes it for this frame.
guiMousePointerSet(MOUSE_POINTER); guiMousePointerSet(MOUSE_POINTER);
// Paint all minimized windows.
surfaceSet(__guiBackBuffer);
_iconCount = 0;
for (i=0; i<arrlen(_windowList); i++) {
widget = (WidgetT *)_windowList[i];
widget->reg->paint(widget, 0);
}
// Paint all windows. // Paint all windows.
_iconCount = 0; _iconCount = 0;
for (i=0; i<arrlen(_windowList); i++) { for (i=0; i<arrlen(_windowList); i++) {
surfaceSet(__guiBackBuffer); surfaceSet(__guiBackBuffer);
widget = (WidgetT *)_windowList[i]; widget = (WidgetT *)_windowList[i];
widget->reg->paint(widget); widget->reg->paint(widget, 1);
} }
// Get top window. // Get top window.

View file

@ -35,6 +35,8 @@
#define ICON_SIZE 32 #define ICON_SIZE 32
#define GADGET_SIZE 20 #define GADGET_SIZE 20
#define WINDOW_PAINT_ICONS 0
#define WINDOW_PAINT_NORMAL 1
#define WIN_NONE 0 #define WIN_NONE 0
#define WIN_CLOSE 1 #define WIN_CLOSE 1

View file

@ -66,7 +66,7 @@ int main(int argc, char *argv[]) {
if (guiStartup(800, 600, 16) == SUCCESS) { if (guiStartup(800, 600, 16) == SUCCESS) {
for (i=1; i<2; i++) { for (i=1; i<4; i++) {
sprintf(title, "Testing %d", i); sprintf(title, "Testing %d", i);
w = windowCreate(i * 50, i * 50, 600, 400, title, WIN_STANDARD, 640, 480); 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); r = radioCreate("Radio C", 1, 0);
widgetAdd(W(w), 220, 140, W(r)); widgetAdd(W(w), 220, 140, W(r));
/*
_v = vscrollCreate(100, clickHandler, NULL); _v = vscrollCreate(100, clickHandler, NULL);
vscrollRangeSet(_v, 0, 640); vscrollRangeSet(_v, 0, 640);
widgetAdd(W(w), 200, 5, W(_v)); 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); s = scrollableCreate(300, 200, 648, 480, SCROLLABLE_STANDARD);
widgetAdd(W(w), 20, 170, W(s)); widgetAdd(W(w), 20, 170, W(s));
*/
} }
guiRun(); guiRun();
guiShutdown(); guiShutdown();