Project split into static library and test program.

This commit is contained in:
Scott Duensing 2022-10-02 15:52:21 -05:00
parent 353ebfb68e
commit a81d3406e0
8 changed files with 113 additions and 107 deletions

1
.gitignore vendored
View file

@ -30,3 +30,4 @@ thirdparty/libpng-1.6.37/.deps/
capture/
*~
*.user

40
master.pro Normal file
View file

@ -0,0 +1,40 @@
#
# Roo/E, the Kangaroo Punch Portable GUI Toolkit
# Copyright (C) 2022 Scott Duensing
#
# http://kangaroopunch.com
#
#
# This file is part of Roo/E.
#
# Roo/E is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Roo/E is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Roo/E. If not, see <https://www.gnu.org/licenses/>.
#
TEMPLATE = subdirs
CONFIG *= ORDERED
SUBDIRS = \
roo-e \
test
OTHER_FILES = \
.gitattributes \
.gitignore \
agpl-3.0.txt \
LICENSE \
build.sh \
Makefile.djgpp \
test.sh \
test.conf

View file

@ -22,11 +22,14 @@
#
TEMPLATE = app
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += console
CONFIG += c99
TEMPLATE = lib
CONFIG -= \
app_bundle \
qt
CONFIG += \
console \
c99 \
staticlib
CONFIG += BACKEND_SDL2
#CONFIG += BACKEND_DJGPP
@ -87,13 +90,9 @@ SOURCES += \
src/gui/widgets/scroll.c \
src/gui/widgets/vscroll.c \
src/gui/wmwindow.c \
src/main.c \
src/platform/djgpp.c \
src/platform/sdl2.c
OTHER_FILES += \
$$PWD/../LICENSE
BACKEND_SDL2 {
DEFINES += BACKEND_SDL2
LIBS += \
@ -102,10 +101,5 @@ BACKEND_SDL2 {
BACKEND_DJGPP {
DEFINES += BACKEND_DJGPP
OTHER_FILES += \
$$PWD/../build.sh \
$$PWD/../Makefile.djgpp \
$$PWD/../test.sh \
$$PWD/../test.conf
}

View file

@ -118,17 +118,6 @@ static void framePaint(struct WidgetS *widget, ...) {
SurfaceT *t = surfaceGet();
PointT o;
PointT w;
uint16_t x;
uint16_t x2;
uint16_t y;
uint16_t i;
unsigned char ul;
unsigned char ur;
unsigned char ll;
unsigned char lr;
unsigned char h;
unsigned char v;
unsigned char s[2];
if (widgetDirtyGet(widget)) {
widgetDirtySet(widget, 0);
@ -140,66 +129,13 @@ static void framePaint(struct WidgetS *widget, ...) {
} else {
w.x = fontWidthGet(f->font);
w.y = fontHeightGet(f->font);
if (f->flags & FRAME_SINGLE) {
// Single line frame.
ul = 218;
ur = 191;
ll = 192;
lr = 217;
h = 196;
v = 179;
} else {
// Double line frame.
ul = 201;
ur = 187;
ll = 200;
lr = 188;
h = 205;
v = 186;
}
fontColorSet(GUI_BLACK, GUI_LIGHTGRAY);
fontModsEnabledSet(1);
s[1] = 0;
// Top line.
x = f->base.r.x;
y = f->base.r.y;
s[0] = ul;
fontRender((char *)s, x, y);
x += w.x;
s[0] = h;
for (i=0; i<f->chars.x - 2; i++) {
fontRender((char *)s, x, y);
x += w.x;
}
x2 = x;
s[0] = ur;
fontRender((char *)s, x, y);
// Title (this incurs some overdraw).
if (f->title) {
fontRender(f->title, f->base.r.x + (w.x * 2), y);
}
// Middle lines.
x = f->base.r.x;
y += w.y;
s[0] = v;
for (i=0; i<f->chars.y - 2; i++) {
fontRender((char *)s, x, y);
fontRender((char *)s, x2, y);
y += w.y;
}
// Bottom line.
s[0] = ll;
fontRender((char *)s, x, y);
x += w.x;
s[0] = h;
for (i=0; i<f->chars.x - 2; i++) {
fontRender((char *)s, x, y);
x += w.x;
}
s[0] = lr;
fontRender((char *)s, x, y);
surfaceBoxHighlight(
f->base.r.x + (w.x * 0.5), f->base.r.y + (w.y * 0.5),
f->base.r.x + f->base.r.w - (w.x * 0.5), f->base.r.y + f->base.r.h - (w.y * 0.5),
(f->flags & FRAME_RAISED) ? GUI_WHITE : GUI_BLACK,
(f->flags & FRAME_RAISED) ? GUI_BLACK : GUI_WHITE
);
if (f->title) fontRender(f->title, f->base.r.x + (w.x * 2), f->base.r.y);
}
// Move the contents to 0,0 to draw it into it's own surface.

View file

@ -30,10 +30,10 @@
#include "../gui.h"
#define FRAME_NONE 0
#define FRAME_SINGLE 1
#define FRAME_DOUBLE 2
#define FRAME_FONT 4 // User will provide font to use.
#define FRAME_NONE 0
#define FRAME_RAISED 1
#define FRAME_DROPPED 2
#define FRAME_FONT 4 // User will provide font to use.
typedef struct FrameS {

View file

@ -132,7 +132,7 @@ void platformShutdown(void) {
uint8_t platformStartup(int16_t width, int16_t height, int16_t depth) {
SDL_PixelFormatEnum pixelFormat;
SDL_PixelFormatEnum pixelFormat = SDL_PIXELFORMAT_ARGB8888;
(void)depth;

View file

@ -36,18 +36,17 @@ int main(int argc, char *argv[]) {
RadioT *r = NULL;
FrameT *f = NULL;
// frame
// layout
// listbox
// canvas
// timer
// textbox
// listbox
// up/down
// terminal
// timer
// msgbox
(void)argc;
memoryStartup(argv[0]);
@ -69,7 +68,7 @@ int main(int argc, char *argv[]) {
c = checkboxCreate("Checkbox", 0);
widgetAdd(W(w), 20, 80, W(c));
f = frameCreate("Frame", 310, 60, FRAME_SINGLE);
f = frameCreate("Frame", 310, 90, FRAME_DROPPED);
widgetAdd(W(w), 20, 110, W(f));
r = radioCreate("Radio 1", 0, 1);
@ -79,21 +78,12 @@ int main(int argc, char *argv[]) {
r = radioCreate("Radio 3", 0, 0);
widgetAdd(W(f), 200, 5, W(r));
/*
r = radioCreate("Radio 1", 0, 1);
widgetAdd(W(w), 20, 110, W(r));
r = radioCreate("Radio 2", 0, 0);
widgetAdd(W(w), 120, 110, W(r));
r = radioCreate("Radio 3", 0, 0);
widgetAdd(W(w), 220, 110, W(r));
r = radioCreate("Radio A", 1, 0);
widgetAdd(W(w), 20, 140, W(r));
widgetAdd(W(f), 0, 35, W(r));
r = radioCreate("Radio B", 1, 1);
widgetAdd(W(w), 120, 140, W(r));
widgetAdd(W(f), 100, 35, W(r));
r = radioCreate("Radio C", 1, 0);
widgetAdd(W(w), 220, 140, W(r));
*/
widgetAdd(W(f), 200, 35, W(r));
}
guiRun();
guiShutdown();

45
test/test.pro Normal file
View file

@ -0,0 +1,45 @@
#
# Roo/E, the Kangaroo Punch Portable GUI Toolkit
# Copyright (C) 2022 Scott Duensing
#
# http://kangaroopunch.com
#
#
# This file is part of Roo/E.
#
# Roo/E is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Roo/E is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Roo/E. If not, see <https://www.gnu.org/licenses/>.
#
TEMPLATE = app
CONFIG -= \
app_bundle \
qt
CONFIG += \
console \
c99
DESTDIR = $$OUT_PWD/bin
INCLUDEPATH += \
$$PWD/../roo-e/src \
$$PWD/../shared \
$$PWD/src
SOURCES += \
src/main.c
LIBS += \
$$PWD/../build-master-debug/roo-e/bin/libroo-e.a \
-lSDL2