Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
00e84f9
fix(wuss): clamp scroll offset after a resize reveals past-extent con…
dpt Aug 30, 2026
dbcb811
feat(wuss): allow the desktop and window backgrounds to be a pattern …
dpt Aug 30, 2026
a418424
fix(wuss): keep a 2px gap at each end of the scrollbar well
dpt Aug 30, 2026
28023e5
refactor(wuss): drop PICO-8 dependency from the NULL-palette default …
dpt Aug 30, 2026
cbc02d0
feat(palettes): add define_wimp16_palette and a WUSS_PALETTE selector
dpt Aug 30, 2026
963f19e
fix(wuss): MENU on furniture should have no effect
dpt Aug 30, 2026
f971b87
fix(wuss): Fix missing text task content when scrolled horizontally
dpt Aug 31, 2026
be48120
docs(wuss): explain how redraw coordinate spaces relate
dpt Aug 31, 2026
7d4644e
refactor(wuss): split the text task's layout and rendering
dpt Aug 31, 2026
da29ca7
feat(bmtext): factor pixel-wrapped text layout into a library
dpt Aug 31, 2026
e9ce0ae
docs(readme): add Text section for txtfmt and bmtext
dpt Aug 31, 2026
d759a6c
refactor(wuss): extract the interactive demo into a standalone app
dpt Aug 31, 2026
88f9172
fix(framebuf): avoid undefined shifts flagged by UBSan
dpt Aug 31, 2026
b0e0f40
test(curve): cut headless frame count from 1000 to 100
dpt Aug 31, 2026
0c36e0a
fix(packer): reclaim released space exactly instead of fragmenting
dpt Aug 31, 2026
0f6c5ef
docs(packer): document packer_release and exact space reclaim
dpt Aug 31, 2026
7f4dc1c
docs: Update
dpt Aug 31, 2026
a28eecd
feat(wuss): add grouping-frame icon type and label justification
dpt Aug 31, 2026
16fb5d6
feat(wuss): add default action button styling for work-area buttons
dpt Aug 31, 2026
408df3f
feat(wuss): add radio and option button icons
dpt Aug 31, 2026
6018ff6
feat(wuss): add plain bitmap icons
dpt Aug 31, 2026
f1fba1b
feat(wuss): add menu-entry icons and hover tracking
dpt Aug 31, 2026
f19964c
feat(wuss): add WUSS_MENUS pop-up menu helper
dpt Aug 31, 2026
db6e02d
feat(wuss): add wuss_menu_create_from_desc descriptor parser
dpt Aug 31, 2026
e69f71a
feat(wuss): menu appearance fixes and screen_draw_dashed_line
dpt Aug 31, 2026
a50c2ba
fix(wuss): draw menu titlebars
dpt Aug 31, 2026
98b2dbb
feat(wuss): dashed menu items draw a rule above and stay pickable
dpt Aug 31, 2026
bfca212
feat(wuss): pluggable allocator via wuss_alloc_t
dpt Sep 1, 2026
2725cee
refactor(wuss): split wuss__icon_draw into per-type sub-functions
dpt Sep 1, 2026
0c38ad6
chore: path-relative header comments across all sources
dpt Sep 1, 2026
429bbab
perf(wuss): skip icon redraw on hover when appearance is hover-indepe…
dpt Sep 1, 2026
8d191a0
fix(wuss): re-resolve the hovered icon after a scroll
dpt Sep 1, 2026
8510756
perf(wuss): blit the still-valid content when a resize re-clamps the …
dpt Sep 1, 2026
5d95242
perf(wuss): blit un-occluded content on scroll when the window is not…
dpt Sep 1, 2026
4c54556
fix(wuss): clip scroll/resize blit repaint set to visible area
dpt Sep 1, 2026
8a65a20
feat(wuss): add Lissajous figure client
dpt Sep 1, 2026
ff7d341
refactor(wuss): use box lib primitives for icon/invalidate box ops
dpt Sep 1, 2026
def9ef9
feat(screen): add screen_draw_lines and unfilled screen_draw_rect
dpt Sep 1, 2026
143654d
refactor(wuss): route core->furniture calls through a dispatch table
dpt Sep 1, 2026
74d23fe
feat(wuss): make menu separators their own short inert row
dpt Sep 1, 2026
76aaee2
refactor(wuss): condense icon pressed/selected/hovered into a flags word
dpt Sep 1, 2026
94cdbf2
feat(screen): add 17-level Bayer dither fill patterns
dpt Sep 1, 2026
ecbb75d
refactor(wuss): show pattern swatches as a 16x16 grid
dpt Sep 1, 2026
d105a9d
feat(screen): use the full 8x8 65-level Bayer dither ramp
dpt Sep 1, 2026
9bcf4ad
feat(wuss): clamp windows so they can never grow larger than the screen
dpt Sep 1, 2026
c7322c4
fix(wuss): give menus an outline
dpt Sep 1, 2026
90418b0
fix(wuss): stop the menu outline cropping the last row
dpt Sep 1, 2026
b5561a6
Revert "fix(wuss): stop the menu outline cropping the last row"
dpt Sep 1, 2026
5689b2a
Revert "fix(wuss): give menus an outline"
dpt Sep 1, 2026
ccfdef5
fix(wuss): restore the Quit row in the app demo menu
dpt Sep 1, 2026
ea0413d
Reapply "fix(wuss): give menus an outline"
dpt Sep 1, 2026
158490f
Reapply "fix(wuss): stop the menu outline cropping the last row"
dpt Sep 1, 2026
a299ebc
refactor(wuss): make menu separators a flag on a real entry plus a RU…
dpt Sep 1, 2026
cdef3f7
fix(wuss): stop scroll blitting content over a mid-content occluder
dpt Sep 1, 2026
b1db2c6
fix(wuss): order scroll blit sub-pieces so one doesn't clobber anothe…
dpt Sep 1, 2026
1221497
docs(wuss): put icon enum/struct member docs before each member
dpt Sep 1, 2026
cddfdf8
refactor(wuss): replace the demo launcher window with a backdrop menu
dpt Sep 1, 2026
9d81727
refactor(wuss): validate icon type with a switch not a chain of !=
dpt Sep 1, 2026
8cff9e4
refactor(wuss): pass NULL for the unused width out-param of bmfont_ge…
dpt Sep 1, 2026
de20588
feat(wuss): add a 'Quit Wuss' task-menu entry that shuts the app down
dpt Sep 1, 2026
1b94b14
fix(wuss): close menu chain before invoking on_select
dpt Sep 1, 2026
dc90dc7
style(wuss): drop horizontal padding from menu rule lines
dpt Sep 1, 2026
0686a50
refactor(wuss): bunch g_* runtime statics into a single struct
dpt Sep 1, 2026
cd4fd21
fix(wuss): don't wheel-scroll windows that declared an axis non-scrol…
dpt Sep 1, 2026
ab85864
feat(wuss): scroll over-tall pop-up menus instead of cropping them
dpt Sep 1, 2026
631af4c
refactor(wuss): split pattern swatches out of icons task
dpt Sep 1, 2026
3d437ff
feat(wuss): add wuss_nearest_colour
dpt Sep 1, 2026
bdcfd36
fix(wuss): draw menu text in the nearest-black palette entry
dpt Sep 1, 2026
da8633d
refactor(wuss): common out ball invalidation box
dpt Sep 1, 2026
accb160
refactor(wuss): drop palette args from test-task constructors
dpt Sep 1, 2026
5c3bfff
refactor(wuss): table-drive the demo chrome palette, tidy task colour…
dpt Sep 1, 2026
259c0d5
fix(wuss): don't blit stale pixels when scrolls arrive faster than re…
dpt Sep 1, 2026
0ec6602
feat(wuss): swap the system palette mid-session
dpt Sep 1, 2026
fe6e083
refactor(wuss): sort the launch menu tasks by name
dpt Sep 1, 2026
27df2fd
fix(wuss): ignore the mouse-up that follows a menu-opening press
dpt Sep 2, 2026
b48fa28
docs(wuss): changelog the menu mouse-up fix
dpt Sep 2, 2026
7504222
docs: fill in CHANGELOG for changes since 671cb53d
dpt Sep 2, 2026
db8d9af
feat(wuss): allow a window as a menu sub-menu
dpt Sep 2, 2026
0b16dae
docs(wuss): changelog the window-as-submenu feature
dpt Sep 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
106 changes: 101 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,74 @@ _Unreleased_ until one is cut.

### Added

- `wuss/icon.h` — work-area icons: static labels and clickable bevelled
buttons drawn inside a window's content area. Icon boxes are in virtual
document space, so they scroll with the content. Wuss hit-tests buttons
before the content task sees a click and delivers them as `wuss_EVENT_ICON`;
labels and hidden or disabled icons fall through as `wuss_EVENT_MOUSE`.
- `wuss/menu.h` (new `WUSS_MENUS` option, implies `WUSS_ICONS`) — RISC OS-style
pop-up menus. `wuss_menu_open()` shows a caller-owned, immutable
`wuss_menu_t` (title plus an array of `wuss_menu_item_t`) as a borderless
window, nudged to stay on screen and opened under the pointer; wuss owns
layout, submenu chaining on hover and whole-chain dismissal. Per-item flags
cover ticks, disabled rows, dashed separators and submenus.
`wuss_menu_select_fn_t` reports a leaf pick — SELECT closes the chain, ADJUST
keeps it open. `wuss_menu_close()` / `wuss_menu_is_open()` manage a chain by
handle. An over-tall menu gets a real vertical scrollbar instead of being
cropped.
- `wuss_menu_create_from_desc()` / `wuss_menu_destroy()` — build a heap
`wuss_menu_t` tree from a compact descriptor string (PrivateEye's
`menu_create_from_desc` syntax: `,` between items, leading `|` for a dashed
separator, `{ ... }` submenus, `!` tick, `~` shade, `>` and `%s` varargs).
The whole tree is one owned allocation graph freed by `wuss_menu_destroy()`.
- `wuss_menu_item_t::window` — a menu row may carry a caller-owned
`wuss_window_t` instead of a `submenu` (the two are mutually exclusive).
Hovering the row shows that window where a submenu would open, using the same
anchor maths; leaving the row, a click outside, a leaf SELECT elsewhere or
`wuss_destroy()` hide it again rather than close it, so the same handle is
reused on the next hover. Create the window with `wuss_WINDOW_HIDDEN`.
- `wuss_window_set_hidden()` and the `wuss_WINDOW_HIDDEN` create flag — a hidden
window keeps its z-order slot but is not drawn, not hit-tested and occludes
nothing. `wuss_window_move()` still works on it (translate only, no blit) so
it can be parked and re-shown in position.
- `wuss_set_palette()` — swap the system palette mid-session. Copies the new
palette in, refreshes the cached nearest-black/white indices, broadcasts a
new `wuss_EVENT_PALETTE` to every window's task so it can recache
`wuss_nearest_colour()` selections, then invalidates the whole screen.
Length must match `wuss_create()`'s; a now-out-of-range furniture/bevel/
backdrop index is rejected with the palette left unchanged.
- `wuss_nearest_colour()` — the system-palette index closest to an RGB value by
squared Euclidean distance, ties to the lower index.
- `wuss_alloc_t` and the `wuss_alloc` stdlib default — pluggable malloc/realloc/
free hooks. `wuss_create()` takes a new `const wuss_alloc_t *` argument
(NULL selects `wuss_alloc`); every heap block a `wuss_t` owns goes through
the hooks.
- `wuss/icon.h` — work-area icons drawn inside a window's content area, in
virtual document space so they scroll with the content. Wuss hit-tests
interactive icons before the content task sees a click and delivers them as
`wuss_EVENT_ICON`; labels and hidden or disabled icons fall through as
`wuss_EVENT_MOUSE`. Icon types: `LABEL` (with `JUSTIFY_RIGHT` / `_CENTRE`
flags), bevelled `BUTTON` (`DEFAULT` flag draws it as the default action
button), `RADIO` and `OPTION` latching buttons (radios with a non-zero
`group` are mutually exclusive), `FRAME` grouping box, `BITMAP` (a
caller-owned image, hit-tested only with the `INTERACTIVE` flag), `PATTERN`
swatch, `MENU_ENTRY` and inert `RULE` rows.
- `wuss_icon_get_selected()` / `wuss_icon_set_selected()` — query and set a
radio or option icon's latched state; setting a grouped radio clears the
others in its group. No task event — the programmatic path.
- `wuss_icon_create_array()` — creates a batch of icons from a spec array with
all-or-nothing rollback: on the first failure any icons already created by
the call are destroyed and no handles are written.
- `text/bmtext.h` — `bmtext_layout()` word-wraps a string to a pixel width in a
`bmfont_t` (measuring each candidate line, so proportional fonts wrap
correctly); `bmtext_draw()` draws the laid-out lines stacked. Layout is pure.
- `screen_draw_lines()` — connected polyline; a `screen_draw_line()` segment
between each adjacent pair.
- `screen_draw_rect()` — one-pixel unfilled rectangle outline (falls back to a
fill for a degenerate size). See _Changed_ for the fill-primitive renames.
- `screen_draw_dashed_line()` — Bresenham line with a dash-period counter.
- `screen_PATTERN_BAYER0` .. `screen_PATTERN_BAYER0 + 64` — 8x8 ordered dither,
one fill pattern per coverage level 0 (empty) to 64 (solid), indexed as
`screen_PATTERN_BAYER0 + level`. `BAYER32` == `GREY50`, `BAYER64` == `SOLID`.
- `define_wimp16_palette()` and the `palette_WIMP16_*` names — the RISC OS
desktop 16-colour palette in native Wimp index order.
- `bitmap_set_palette()` — replace a bitmap's palette in place, reusing the
existing palette buffer when it is large enough; NULL drops the palette.
- `wuss_window_create_placed()` — creates a window from a content size instead
of a box, letting Wuss pack it (furniture included) into the first free
screen region. Successive auto-placed windows tile; placement cascades when
Expand Down Expand Up @@ -57,6 +117,24 @@ _Unreleased_ until one is cut.

### Changed

- **Breaking:** `wuss_create()` takes a `const wuss_alloc_t *alloc` argument
after `config`; pass NULL for the stdlib allocator.
- **Breaking:** `wuss_config_t::palette` is renamed `furniture`, and its type
`wuss_palette_t` renamed `wuss_furniture_palette_t`. `wuss_colour_t` narrows
from `int` to `unsigned char`.
- **Breaking:** the framebuf draw primitives split draw/fill in their names:
`screen_draw_pixel` → `screen_set_pixel`, `screen_draw_rect` →
`screen_fill_rect`, `screen_draw_square` → `screen_fill_square`. `screen_draw_rect`
now names a one-pixel outline.
- **Breaking:** the window/desktop background is now a `wuss_backdrop_t`
(`{ colour, pattern, pattern_bg }`) instead of a bare `wuss_colour_t`:
`wuss_config_t::backdrop`, and the `bg` parameter of
`wuss_window_create()`, `wuss_window_create_placed()` and
`wuss_window_set_background()`. A non-`screen_PATTERN_SOLID` `pattern` fills
with `screen_fill_pattern()` — the desktop phased to the screen origin, a
window's content phased to its scroll origin so the pattern stays locked to
the content. `wuss_BACKDROP_COLOUR(c)` and `wuss_BACKDROP_PATTERN(c, p, b)`
build one; the flat-colour case is `wuss_BACKDROP_COLOUR(old_value)`.
- **Breaking:** `wuss_button_t` values are now flags (`wuss_BUTTON_SELECT` 4,
`wuss_BUTTON_MENU` 2, `wuss_BUTTON_ADJUST` 1, `wuss_BUTTON_NONE` 0) so
chords such as Select+Adjust can be reported. Client code comparing a
Expand All @@ -68,14 +146,32 @@ _Unreleased_ until one is cut.
- Adjust-clicking a scroll arrow now steps against the direction the arrow
points, so one arrow can be worked both ways without moving the pointer.
Toggle-size stays Select-only.
- A window can no longer be resized larger than the screen.

### Fixed

- Opening a menu from a task's mouse-down handler no longer picks the menu's
first row on the matching mouse-up: that release is now swallowed.
- A menu chain is now closed before its `on_select` callback runs, so a
callback that opens another menu no longer fights the one being torn down.
- Menu text is drawn in the nearest-black palette entry rather than assuming
a fixed index, so menus stay legible under any system palette.
- The mouse wheel no longer scrolls a window on an axis it declared
non-scrollable.
- A MENU-button click on window furniture now has no effect, instead of being
routed to the content task.
- A window's scroll offset is re-clamped after a resize reveals content past
the document extent.
- The scrollbar well keeps a 2px gap at each end.
- Dragging a scrollbar well with Select no longer raises the window; only a
resize-icon grab restacks it.
- `wuss_window_move()` no longer repaints already-blitted pixels when a drag
past an occluded corner slides one clean piece of the window onto ground
another clean piece just vacated.
- Several scroll-redraw glitches fixed: stale pixels when scroll events arrive
faster than redraws, content blitted over a mid-content occluder, blit
sub-pieces clobbering each other's source region, and repaint sets not
clipped to the visible area. The hovered icon is re-resolved after a scroll.
- A work-area button held on mouse-down is now released if the click opens a
window that covers the button's owner, instead of staying stuck pressed.
- Resize-corner drag preserves where within the resize icon the mouse-down
Expand Down
117 changes: 90 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ endif(CCACHE_FOUND)
option(USE_FORTIFY "Use Fortify" OFF)
option(USE_ASAN "Build with AddressSanitizer and UndefinedBehaviorSanitizer" OFF)
option(DPTLIB_IMAGES_READ_ONLY "Remove libpng write support" OFF)
option(WUSS_FURNITURE "Build the wuss window-furniture subsystem" ON)
option(WUSS_ICONS "Build the wuss in-content icon subsystem" ON)
option(WUSS_FURNITURE "Build the Wuss window-furniture subsystem" ON)
option(WUSS_ICONS "Build the Wuss in-content icon subsystem" ON)
option(WUSS_MENUS "Build the Wuss pop-up menu helper (implies WUSS_ICONS)" ON)

# Referencing CMAKE_TOOLCHAIN_FILE avoids a warning on rebuilds.
if(NOT ${CMAKE_TOOLCHAIN_FILE} STREQUAL "")
Expand Down Expand Up @@ -105,6 +106,7 @@ set(PUBLIC_HEADERS
include/io/stream.h
include/test/all-tests.h
include/test/txtscr.h
include/text/bmtext.h
include/text/txtfmt.h
include/utils/array.h
include/utils/barith.h
Expand All @@ -121,6 +123,9 @@ set(PUBLIC_HEADERS
if(WUSS_ICONS)
list(APPEND PUBLIC_HEADERS include/wuss/icon.h)
endif()
if(WUSS_MENUS)
list(APPEND PUBLIC_HEADERS include/wuss/menu.h)
endif()

# The public headers must be set as properties of the library, not as
# target_sources. The quoting is essential.
Expand Down Expand Up @@ -285,6 +290,8 @@ set(TESTLIB_SOURCES
libraries/test/txtscr/txtscr.c)

set(TEXT_SOURCES
libraries/text/bmtext/draw.c
libraries/text/bmtext/layout.c
libraries/text/txtfmt/create.c
libraries/text/txtfmt/destroy.c
libraries/text/txtfmt/get-length.c
Expand Down Expand Up @@ -326,17 +333,21 @@ set(UTILS_SOURCES
libraries/utils/primes/primes.c)

set(WUSS_CORE_SOURCES
libraries/wuss/backdrop.c
libraries/wuss/create.c
libraries/wuss/destroy.c
libraries/wuss/get-font.c
libraries/wuss/get-pointer.c
libraries/wuss/idle.c
libraries/wuss/impl.h
libraries/wuss/invalidate.c
libraries/wuss/mouse-click.c
libraries/wuss/mouse-move.c
libraries/wuss/nearest-colour.c
libraries/wuss/redraw.c
libraries/wuss/scroll.c
libraries/wuss/scroll-step.c
libraries/wuss/set-palette.c
libraries/wuss/task/start.c
libraries/wuss/task/stop.c
libraries/wuss/window/at.c
Expand All @@ -351,6 +362,7 @@ set(WUSS_CORE_SOURCES
libraries/wuss/window/resize.c
libraries/wuss/window/restack.c
libraries/wuss/window/set-background.c
libraries/wuss/window/set-hidden.c
libraries/wuss/window/set-scroll.c)

set(WUSS_FURNITURE_SOURCES
Expand All @@ -362,6 +374,7 @@ set(WUSS_FURNITURE_SOURCES
libraries/wuss/furniture/hit-test.c
libraries/wuss/furniture/hscroll-box.c
libraries/wuss/furniture/invalidate.c
libraries/wuss/furniture/ops.c
libraries/wuss/furniture/resize-box.c
libraries/wuss/furniture/scroll-action.c
libraries/wuss/furniture/titlebar-box.c
Expand All @@ -377,23 +390,37 @@ set(WUSS_ICON_SOURCES
libraries/wuss/icon/draw.c
libraries/wuss/icon/free.c
libraries/wuss/icon/get-bbox.c
libraries/wuss/icon/get-selected.c
libraries/wuss/icon/get-text.c
libraries/wuss/icon/get-type.c
libraries/wuss/icon/get-window.c
libraries/wuss/icon/hit-test.c
libraries/wuss/icon/invalidate.c
libraries/wuss/icon/screen-box.c
libraries/wuss/icon/set-hidden.c
libraries/wuss/icon/set-hover.c
libraries/wuss/icon/set-selected.c
libraries/wuss/icon/set-text.c
libraries/wuss/icon.h)

set(WUSS_MENU_SOURCES
libraries/wuss/menu/menu.c
libraries/wuss/menu/create-from-desc.c
libraries/wuss/menu.h)

set(WUSS_SOURCES ${WUSS_CORE_SOURCES})
if(WUSS_FURNITURE)
list(APPEND WUSS_SOURCES ${WUSS_FURNITURE_SOURCES})
endif()
if(WUSS_MENUS)
set(WUSS_ICONS ON) # the menu helper needs the icon subsystem
endif()
if(WUSS_ICONS)
list(APPEND WUSS_SOURCES ${WUSS_ICON_SOURCES})
endif()
if(WUSS_MENUS)
list(APPEND WUSS_SOURCES ${WUSS_MENU_SOURCES})
endif()

set(ALL_SOURCES
${PUBLIC_HEADERS}
Expand Down Expand Up @@ -451,6 +478,9 @@ endif()
if(WUSS_ICONS)
target_compile_definitions(DPTLib PUBLIC WUSS_ICONS)
endif()
if(WUSS_MENUS)
target_compile_definitions(DPTLib PUBLIC WUSS_MENUS)
endif()

if(NOT TARGET_RISCOS)
set(CMAKE_FIND_FRAMEWORK NEVER)
Expand Down Expand Up @@ -560,6 +590,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include

option(BUILD_TESTS "Build test program" OFF)
option(BUILD_SDL_TESTS "Build tests that use SDL" OFF)
option(BUILD_APPS "Build standalone apps (Wuss interactive demo)" OFF)

if(BUILD_TESTS)
set(TEST_SOURCES
Expand Down Expand Up @@ -587,27 +618,8 @@ if(BUILD_TESTS)
libraries/utils/bsearch/test/bsearch-test.c
libraries/utils/pack/test/pack-test.c
libraries/datastruct/vector/test/vector-test.c
libraries/wuss/test/tasks/ball.c
libraries/wuss/test/tasks/blank.c
libraries/wuss/test/tasks/chars.c
libraries/wuss/test/tasks/checker.c
libraries/wuss/test/tasks/curve.c
libraries/wuss/test/tasks/gradient.c
libraries/wuss/test/tasks/image.c
libraries/wuss/test/tasks/palette.c
libraries/wuss/test/tasks/porter-duff.c
libraries/wuss/test/tasks/sofa.c
libraries/wuss/test/tasks/text.c
libraries/wuss/test/wuss-test.c)

# The icon-driven launcher and the icons task only build when both wuss
# subsystems are present; the SDL interactive driver needs them too.
if(WUSS_FURNITURE AND WUSS_ICONS)
list(APPEND TEST_SOURCES
libraries/wuss/test/tasks/icons.c
libraries/wuss/test/tasks/launcher.c)
endif()

source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${TEST_SOURCES})

# Avoid a warning from CMake
Expand All @@ -630,19 +642,70 @@ if(BUILD_TESTS)
target_link_libraries(DPTLibTest m)
endif()

# Some unit tests (e.g. bmfont-test) gate an interactive SDL mode on
# USE_SDL; BUILD_SDL_TESTS links SDL3 and defines it for the test binary.
if(BUILD_SDL_TESTS)
if(NOT (WUSS_FURNITURE AND WUSS_ICONS))
message(FATAL_ERROR "BUILD_SDL_TESTS requires WUSS_FURNITURE and WUSS_ICONS")
endif()

find_package(SDL3 REQUIRED)
find_package(SDL3_image REQUIRED)

target_link_libraries(DPTLibTest SDL3::SDL3 SDL3_image::SDL3_image)

target_compile_definitions(DPTLibTest PUBLIC USE_SDL)
target_compile_definitions(DPTLibTest PRIVATE USE_SDL)
endif()

install(TARGETS DPTLibTest RUNTIME
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()


# Standalone apps
#

if(BUILD_APPS)
# The Wuss interactive demo: its own executable, built from the SDL task
# modules plus apps/wuss/main.c (which was the old in-test SDL driver).
if(NOT (WUSS_FURNITURE AND WUSS_ICONS))
message(FATAL_ERROR "BUILD_APPS requires WUSS_FURNITURE and WUSS_ICONS")
endif()

find_package(SDL3 REQUIRED)
find_package(SDL3_image REQUIRED)

set(WUSS_APP_SOURCES
apps/wuss/main.c
libraries/wuss/test/tasks/ball.c
libraries/wuss/test/tasks/blank.c
libraries/wuss/test/tasks/chars.c
libraries/wuss/test/tasks/checker.c
libraries/wuss/test/tasks/curve.c
libraries/wuss/test/tasks/gradient.c
libraries/wuss/test/tasks/icons.c
libraries/wuss/test/tasks/image.c
libraries/wuss/test/tasks/lissajous.c
libraries/wuss/test/tasks/palette.c
libraries/wuss/test/tasks/porter-duff.c
libraries/wuss/test/tasks/sofa.c
libraries/wuss/test/tasks/swatches.c
libraries/wuss/test/tasks/text.c)

source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${WUSS_APP_SOURCES})

add_executable(wuss ${WUSS_APP_SOURCES})

set_target_properties(wuss PROPERTIES
DESCRIPTION "DPTLib Wuss interactive demo"
C_STANDARD 99
OUTPUT_NAME_DEBUG wuss-debug
OUTPUT_NAME_RELEASE wuss
OUTPUT_NAME_RELWITHDEBINFO wuss-relwithdebinfo
OUTPUT_NAME_MINSIZEREL wuss-minsizerel)

target_include_directories(wuss PRIVATE libraries/wuss/test)
target_compile_definitions(wuss PRIVATE USE_SDL)
target_link_libraries(wuss DPTLib SDL3::SDL3 SDL3_image::SDL3_image)
if(NOT MSVC)
target_link_libraries(wuss m)
endif()

install(TARGETS wuss RUNTIME
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ DPTLib is my platform independent C library. It contains a wide variety of funct

- [`test/txtscr.h`](https://github.com/dpt/DPTLib/blob/master/include/test/txtscr.h) — text format 'screen'

### Text

- [`text/txtfmt.h`](https://github.com/dpt/DPTLib/blob/master/include/text/txtfmt.h) — word-wrap a string to a character width (for monospaced text)
- [`text/bmtext.h`](https://github.com/dpt/DPTLib/blob/master/include/text/bmtext.h) — word-wrap and draw a paragraph to a pixel width in a `bmfont`

### Utilities

- [`utils/array.h`](https://github.com/dpt/DPTLib/blob/master/include/utils/array.h) — array utilities
Expand Down
2 changes: 1 addition & 1 deletion apps/test/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
/* test/main.c */
// main.c
// DPTLibTest
//
Expand Down
Loading