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,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; yc<ICON_SIZE; yc++) {
y += yi;
px = (ICON_SIZE + 1) * _iconCount;
for (xc=0; xc<ICON_SIZE; xc++) {
x += xi;
surfacePixelSet(px++, py, surfacePixelGet(w->scroll->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; yc<ICON_SIZE; yc++) {
y += yi;
px = (ICON_SIZE + 1) * _iconCount;
for (xc=0; xc<ICON_SIZE; xc++) {
x += xi;
surfacePixelSet(px++, py, surfacePixelGet(w->scroll->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; i<arrlen(_windowList); i++) {
widget = (WidgetT *)_windowList[i];
widget->reg->paint(widget, 0);
}
// Paint all windows.
_iconCount = 0;
for (i=0; i<arrlen(_windowList); i++) {
surfaceSet(__guiBackBuffer);
widget = (WidgetT *)_windowList[i];
widget->reg->paint(widget);
widget->reg->paint(widget, 1);
}
// Get top window.

View file

@ -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

View file

@ -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();