Compare commits

..

No commits in common. "90c6ab68e3247323daf572005730da1f72bc6d6e" and "76a955a9e7c5e46bc91614f42dceb144c465034f" have entirely different histories.

10 changed files with 40 additions and 165 deletions

2
.gitignore vendored
View file

@ -1,7 +1,5 @@
dosbench/ dosbench/
bin/ bin/
obj/ obj/
lib/
*.~ *.~
.gitignore~
DVX_GUI_DESIGN.md DVX_GUI_DESIGN.md

View file

@ -1,17 +1,15 @@
# DV/X GUI Library Makefile for DJGPP cross-compilation # DV/X GUI Makefile for DJGPP cross-compilation
DJGPP_PREFIX = $(HOME)/djgpp/djgpp DJGPP_PREFIX = $(HOME)/djgpp/djgpp
CC = $(DJGPP_PREFIX)/bin/i586-pc-msdosdjgpp-gcc CC = $(DJGPP_PREFIX)/bin/i586-pc-msdosdjgpp-gcc
DJGPP_LIBPATH = $(HOME)/claude/windriver/tools/lib
AR = LD_LIBRARY_PATH=$(DJGPP_LIBPATH) $(DJGPP_PREFIX)/bin/i586-pc-msdosdjgpp-ar
RANLIB = LD_LIBRARY_PATH=$(DJGPP_LIBPATH) $(DJGPP_PREFIX)/bin/i586-pc-msdosdjgpp-ranlib
CFLAGS = -O2 -Wall -Wextra -march=i486 -mtune=i586 CFLAGS = -O2 -Wall -Wextra -march=i486 -mtune=i586
LDFLAGS = -lm
OBJDIR = ../obj/dvx OBJDIR = ../obj
WOBJDIR = ../obj/dvx/widgets WOBJDIR = ../obj/widgets
LIBDIR = ../lib BINDIR = ../bin
SRCS = dvxVideo.c dvxDraw.c dvxComp.c dvxWm.c dvxIcon.c dvxImageWrite.c dvxApp.c SRCS = dvxVideo.c dvxDraw.c dvxComp.c dvxWm.c dvxIcon.c dvxImageWrite.c dvxApp.c demo.c
WSRCS = widgets/widgetCore.c \ WSRCS = widgets/widgetCore.c \
widgets/widgetLayout.c \ widgets/widgetLayout.c \
@ -39,15 +37,14 @@ WSRCS = widgets/widgetCore.c \
OBJS = $(patsubst %.c,$(OBJDIR)/%.o,$(SRCS)) OBJS = $(patsubst %.c,$(OBJDIR)/%.o,$(SRCS))
WOBJS = $(patsubst widgets/%.c,$(WOBJDIR)/%.o,$(WSRCS)) WOBJS = $(patsubst widgets/%.c,$(WOBJDIR)/%.o,$(WSRCS))
TARGET = $(LIBDIR)/libdvx.a TARGET = $(BINDIR)/demo.exe
.PHONY: all clean .PHONY: all clean
all: $(TARGET) all: $(TARGET)
$(TARGET): $(OBJS) $(WOBJS) | $(LIBDIR) $(TARGET): $(OBJS) $(WOBJS) | $(BINDIR)
$(AR) rcs $@ $(OBJS) $(WOBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(WOBJS)
$(RANLIB) $@
$(OBJDIR)/%.o: %.c | $(OBJDIR) $(OBJDIR)/%.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) -c -o $@ $<
@ -61,8 +58,8 @@ $(OBJDIR):
$(WOBJDIR): $(WOBJDIR):
mkdir -p $(WOBJDIR) mkdir -p $(WOBJDIR)
$(LIBDIR): $(BINDIR):
mkdir -p $(LIBDIR) mkdir -p $(BINDIR)
# Dependencies # Dependencies
$(OBJDIR)/dvxVideo.o: dvxVideo.c dvxVideo.h dvxTypes.h dvxPalette.h $(OBJDIR)/dvxVideo.o: dvxVideo.c dvxVideo.h dvxTypes.h dvxPalette.h
@ -72,6 +69,7 @@ $(OBJDIR)/dvxWm.o: dvxWm.c dvxWm.h dvxTypes.h dvxDraw.h dvxComp.h dvxVid
$(OBJDIR)/dvxIcon.o: dvxIcon.c thirdparty/stb_image.h $(OBJDIR)/dvxIcon.o: dvxIcon.c thirdparty/stb_image.h
$(OBJDIR)/dvxImageWrite.o: dvxImageWrite.c thirdparty/stb_image_write.h $(OBJDIR)/dvxImageWrite.o: dvxImageWrite.c thirdparty/stb_image_write.h
$(OBJDIR)/dvxApp.o: dvxApp.c dvxApp.h dvxTypes.h dvxVideo.h dvxDraw.h dvxComp.h dvxWm.h dvxFont.h dvxCursor.h $(OBJDIR)/dvxApp.o: dvxApp.c dvxApp.h dvxTypes.h dvxVideo.h dvxDraw.h dvxComp.h dvxWm.h dvxFont.h dvxCursor.h
$(OBJDIR)/demo.o: demo.c dvxApp.h dvxWidget.h
# Widget file dependencies # Widget file dependencies
WIDGET_DEPS = widgets/widgetInternal.h dvxWidget.h dvxTypes.h dvxApp.h dvxDraw.h dvxWm.h dvxVideo.h WIDGET_DEPS = widgets/widgetInternal.h dvxWidget.h dvxTypes.h dvxApp.h dvxDraw.h dvxWm.h dvxVideo.h
@ -100,4 +98,4 @@ $(WOBJDIR)/widgetToolbar.o: widgets/widgetToolbar.c $(WIDGET_DEPS)
$(WOBJDIR)/widgetTreeView.o: widgets/widgetTreeView.c $(WIDGET_DEPS) $(WOBJDIR)/widgetTreeView.o: widgets/widgetTreeView.c $(WIDGET_DEPS)
clean: clean:
rm -rf $(OBJDIR) $(LIBDIR) rm -rf $(OBJDIR) $(BINDIR)

View file

@ -54,10 +54,7 @@ static void compositeAndFlush(AppContextT *ctx) {
// 1. Draw desktop background // 1. Draw desktop background
rectFill(d, ops, dr->x, dr->y, dr->w, dr->h, ctx->colors.desktop); rectFill(d, ops, dr->x, dr->y, dr->w, dr->h, ctx->colors.desktop);
// 2. Draw minimized window icons (under all windows) // 2. Walk window stack bottom-to-top
wmDrawMinimizedIcons(d, ops, &ctx->colors, ws, dr);
// 3. Walk window stack bottom-to-top
for (int32_t j = 0; j < ws->count; j++) { for (int32_t j = 0; j < ws->count; j++) {
WindowT *win = ws->windows[j]; WindowT *win = ws->windows[j];
@ -80,7 +77,10 @@ static void compositeAndFlush(AppContextT *ctx) {
} }
} }
// 4. Draw popup menu if active // 2b. Draw minimized window icons
wmDrawMinimizedIcons(d, ops, &ctx->colors, ws, dr);
// 3. Draw popup menu if active
if (ctx->popup.active) { if (ctx->popup.active) {
// Draw popup dropdown // Draw popup dropdown
RectT popRect = { RectT popRect = {
@ -484,21 +484,7 @@ void dvxQuit(AppContextT *ctx) {
// ============================================================ // ============================================================
void dvxRun(AppContextT *ctx) { void dvxRun(AppContextT *ctx) {
while (dvxUpdate(ctx)) { while (ctx->running) {
// dvxUpdate returns false when the GUI wants to exit
}
}
// ============================================================
// dvxUpdate
// ============================================================
bool dvxUpdate(AppContextT *ctx) {
if (!ctx->running) {
return false;
}
pollMouse(ctx); pollMouse(ctx);
pollKeyboard(ctx); pollKeyboard(ctx);
dispatchEvents(ctx); dispatchEvents(ctx);
@ -513,8 +499,7 @@ bool dvxUpdate(AppContextT *ctx) {
ctx->prevMouseX = ctx->mouseX; ctx->prevMouseX = ctx->mouseX;
ctx->prevMouseY = ctx->mouseY; ctx->prevMouseY = ctx->mouseY;
ctx->prevMouseButtons = ctx->mouseButtons; ctx->prevMouseButtons = ctx->mouseButtons;
}
return ctx->running;
} }

View file

@ -48,10 +48,6 @@ void dvxShutdown(AppContextT *ctx);
// Run the main event loop (returns when ctx->running is set to false) // Run the main event loop (returns when ctx->running is set to false)
void dvxRun(AppContextT *ctx); void dvxRun(AppContextT *ctx);
// Process one iteration of the event loop.
// Returns true if the GUI is still running, false if it wants to exit.
bool dvxUpdate(AppContextT *ctx);
// Create a window // Create a window
WindowT *dvxCreateWindow(AppContextT *ctx, const char *title, WindowT *dvxCreateWindow(AppContextT *ctx, const char *title,
int32_t x, int32_t y, int32_t w, int32_t h, int32_t x, int32_t y, int32_t w, int32_t h,

View file

@ -446,13 +446,6 @@ void wgtListBoxSetItems(WidgetT *w, const char **items, int32_t count);
int32_t wgtListBoxGetSelected(const WidgetT *w); int32_t wgtListBoxGetSelected(const WidgetT *w);
void wgtListBoxSetSelected(WidgetT *w, int32_t idx); void wgtListBoxSetSelected(WidgetT *w, int32_t idx);
// ============================================================
// Debug
// ============================================================
// Draw borders around layout containers in ugly colors
void wgtSetDebugLayout(bool enabled);
// ============================================================ // ============================================================
// Layout (called internally; available for manual trigger) // Layout (called internally; available for manual trigger)
// ============================================================ // ============================================================

View file

@ -6,7 +6,6 @@
// Global state for drag and popup tracking // Global state for drag and popup tracking
// ============================================================ // ============================================================
bool sDebugLayout = false;
WidgetT *sOpenPopup = NULL; WidgetT *sOpenPopup = NULL;
WidgetT *sDragSlider = NULL; WidgetT *sDragSlider = NULL;
WidgetT *sDrawingCanvas = NULL; WidgetT *sDrawingCanvas = NULL;

View file

@ -42,7 +42,6 @@
// Shared state (defined in widgetCore.c) // Shared state (defined in widgetCore.c)
// ============================================================ // ============================================================
extern bool sDebugLayout;
extern WidgetT *sOpenPopup; extern WidgetT *sOpenPopup;
extern WidgetT *sDragSlider; extern WidgetT *sDragSlider;
extern WidgetT *sDrawingCanvas; extern WidgetT *sDrawingCanvas;

View file

@ -3,40 +3,6 @@
#include "widgetInternal.h" #include "widgetInternal.h"
// ============================================================
// debugContainerBorder
// ============================================================
//
// Draw a 1px border in a garish neon color derived from the widget
// pointer so every container gets a distinct, ugly color.
static void debugContainerBorder(WidgetT *w, DisplayT *d, const BlitOpsT *ops) {
static const uint8_t palette[][3] = {
{255, 0, 255}, // magenta
{ 0, 255, 0}, // lime
{255, 255, 0}, // yellow
{ 0, 255, 255}, // cyan
{255, 128, 0}, // orange
{128, 0, 255}, // purple
{255, 0, 128}, // hot pink
{ 0, 128, 255}, // sky blue
{128, 255, 0}, // chartreuse
{255, 64, 64}, // salmon
{ 64, 255, 128}, // mint
{255, 128, 255}, // orchid
};
uint32_t h = (uint32_t)(uintptr_t)w * 2654435761u;
int32_t idx = (int32_t)((h >> 16) % 12);
uint32_t color = packColor(d, palette[idx][0], palette[idx][1], palette[idx][2]);
drawHLine(d, ops, w->x, w->y, w->w, color);
drawHLine(d, ops, w->x, w->y + w->h - 1, w->w, color);
drawVLine(d, ops, w->x, w->y, w->h, color);
drawVLine(d, ops, w->x + w->w - 1, w->y, w->h, color);
}
// ============================================================ // ============================================================
// widgetPaintOne // widgetPaintOne
// ============================================================ // ============================================================
@ -114,9 +80,6 @@ void widgetPaintOne(WidgetT *w, DisplayT *d, const BlitOpsT *ops,
case WidgetTabControlE: case WidgetTabControlE:
widgetTabControlPaint(w, d, ops, font, colors); widgetTabControlPaint(w, d, ops, font, colors);
if (sDebugLayout) {
debugContainerBorder(w, d, ops);
}
return; // handles its own children return; // handles its own children
case WidgetStatusBarE: case WidgetStatusBarE:
@ -129,9 +92,6 @@ void widgetPaintOne(WidgetT *w, DisplayT *d, const BlitOpsT *ops,
case WidgetTreeViewE: case WidgetTreeViewE:
widgetTreeViewPaint(w, d, ops, font, colors); widgetTreeViewPaint(w, d, ops, font, colors);
if (sDebugLayout) {
debugContainerBorder(w, d, ops);
}
return; // handles its own children return; // handles its own children
default: default:
@ -142,11 +102,6 @@ void widgetPaintOne(WidgetT *w, DisplayT *d, const BlitOpsT *ops,
for (WidgetT *c = w->firstChild; c; c = c->nextSibling) { for (WidgetT *c = w->firstChild; c; c = c->nextSibling) {
widgetPaintOne(c, d, ops, font, colors); widgetPaintOne(c, d, ops, font, colors);
} }
// Debug: draw container borders on top of children
if (sDebugLayout && w->firstChild) {
debugContainerBorder(w, d, ops);
}
} }
@ -355,15 +310,6 @@ void wgtPaint(WidgetT *root, DisplayT *d, const BlitOpsT *ops,
} }
// ============================================================
// wgtSetDebugLayout
// ============================================================
void wgtSetDebugLayout(bool enabled) {
sDebugLayout = enabled;
}
// ============================================================ // ============================================================
// wgtSetEnabled // wgtSetEnabled
// ============================================================ // ============================================================

View file

@ -1,39 +0,0 @@
# DV/X GUI Demo Makefile for DJGPP cross-compilation
DJGPP_PREFIX = $(HOME)/djgpp/djgpp
CC = $(DJGPP_PREFIX)/bin/i586-pc-msdosdjgpp-gcc
CFLAGS = -O2 -Wall -Wextra -march=i486 -mtune=i586 -I../dvx
LDFLAGS = -L../lib -ldvx -lm
OBJDIR = ../obj/dvxdemo
BINDIR = ../bin
LIBDIR = ../lib
SRCS = demo.c
OBJS = $(patsubst %.c,$(OBJDIR)/%.o,$(SRCS))
TARGET = $(BINDIR)/demo.exe
.PHONY: all clean lib
all: lib $(TARGET)
lib:
$(MAKE) -C ../dvx
$(TARGET): $(OBJS) $(LIBDIR)/libdvx.a | $(BINDIR)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
$(OBJDIR)/%.o: %.c | $(OBJDIR)
$(CC) $(CFLAGS) -c -o $@ $<
$(OBJDIR):
mkdir -p $(OBJDIR)
$(BINDIR):
mkdir -p $(BINDIR)
# Dependencies
$(OBJDIR)/demo.o: demo.c ../dvx/dvxApp.h ../dvx/dvxWidget.h
clean:
rm -rf $(OBJDIR) $(BINDIR)