CSS: Reaktor's own engine replaces libcss, and a pass of simplifications
core/css/css.c reads the stylesheets once into typed values and cascades them as CSS does: !important, then specificity, then source order. It takes var(), color-mix(in srgb, ...), em and rem, calc() over pixels, the @media features Reaktor answers, @import at the top of a sheet, :not(), :enabled, attribute selectors read as classes, descendant and child combinators, and escapes. Rules are bucketed by the last compound of their selector, so a query checks only the rules that could match. cssflat.c, LCUI's libcss and yutil, and the lcui submodule go. Screenshots of every showcase tab, notepad and simple, light and dark, with normal and more contrast, are byte-identical to the libcss build, with Water.css and with Simple.css; --a11y-dump differs only in the a11y struct's size. Three values change to what CSS says: an unset background is transparent black, an unset border color is the text's, and Simple.css's :enabled:hover no longer reaches a disabled button. Against libcss, loading the sheets takes 0.35 ms instead of 1.24 and a first query 0.32 us instead of 4.4. csstest covers the cascade, values, @media and hostile sheets: import loops and fan-out, var() that grows or expands too often, deep calc(), a sheet left open, a huge file. 200,000 mutated sheets ran clean under AddressSanitizer. Simplifications: dead state (redraw_always, sw_noaa, the hover-gap pin, a muted note, an overwritten slider range, the font-baking blocks of the SDL renderer, the a11y change index); REAKTOR_LAY_FILL for FILL_X | FILL_Y; one helper each for flag parsing, capture runs, timings, paths from the working directory, array growth, focus moves, tooltips, button presses, a11y slot probes, UIA fragments and test strings; launchtest's notef() and last_node(); the output folder set once in CMake and a write-if-changed function; one test list, tools/ci/tests.txt, for every workflow, so basetest and imagetest run. The showcase drops its relaunch button, an ask() button is as wide as its label, and build.sh takes a bare target. The docs follow, and PERFORMANCE.md and the chart carry a new pass of all seven benchmark arms on one machine. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7bf48d453a
commit
dffcce22d5
@@ -193,8 +193,7 @@ jobs:
|
||||
echo "the package carries the sysroot's path"; exit 1
|
||||
fi
|
||||
tar -cf cross-${{ matrix.os }}-arm64.tar \
|
||||
build-arm64/onlaytest build-arm64/keytest build-arm64/a11ytest build-arm64/animtest \
|
||||
build-arm64/localetest build-arm64/laytest build-arm64/texttest build-arm64/csstest \
|
||||
$(sed 's|^|build-arm64/|' tools/ci/tests.txt) \
|
||||
build-arm64/showcase build-arm64/notepad build-arm64/simple build-arm64/bench \
|
||||
build-arm64/licenses build-arm64/CMakeCache.txt "dist/$name"
|
||||
|
||||
@@ -247,7 +246,7 @@ jobs:
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
fail=0
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest csstest; do
|
||||
for t in $(cat tools/ci/tests.txt); do
|
||||
echo "== $t"
|
||||
if ./build/$t </dev/null; then :; else echo "$t: exit status $?"; fail=1; fi
|
||||
done
|
||||
@@ -462,7 +461,7 @@ jobs:
|
||||
id: tests
|
||||
run: |
|
||||
fail=0
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest csstest; do
|
||||
for t in $(cat tools/ci/tests.txt); do
|
||||
echo "== $t"
|
||||
if ./build-arm64/$t </dev/null; then :; else echo "$t: exit status $?"; fail=1; fi
|
||||
done
|
||||
|
||||
@@ -131,7 +131,7 @@ jobs:
|
||||
run: |
|
||||
docker exec -i debian sh -u <<'EOF'
|
||||
fail=0
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest csstest; do
|
||||
for t in $(cat tools/ci/tests.txt); do
|
||||
echo "== $t"
|
||||
if ./build/$t </dev/null; then :; else echo "$t: exit status $?"; fail=1; fi
|
||||
done
|
||||
|
||||
@@ -74,7 +74,7 @@ jobs:
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
fail=0
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest csstest; do
|
||||
for t in $(cat tools/ci/tests.txt); do
|
||||
echo "== $t"
|
||||
if ./build/$t </dev/null; then :; else echo "$t: exit status $?"; fail=1; fi
|
||||
done
|
||||
|
||||
@@ -138,7 +138,7 @@ jobs:
|
||||
systems and architectures, \`libreaktor-$v-<system>-<arch>\`, and
|
||||
\`libreaktor-$v-wasm.tar.gz\`. Each holds one static library (\`reaktor.lib\`
|
||||
on Windows, built against the DLL C runtime; \`libreaktor.a\` elsewhere)
|
||||
with SDL, FreeType, libcss, plutosvg, Onlay, NukAnim, mojibake and kb_text_shape
|
||||
with SDL, FreeType, plutosvg, Onlay, NukAnim, mojibake and kb_text_shape
|
||||
inside it, the public headers (\`#include "reaktor/reaktor.h"\`, with
|
||||
Nuklear's, NukAnim's and SDL's), a CMake package and a pkg-config file,
|
||||
and the licenses.
|
||||
|
||||
@@ -95,7 +95,7 @@ jobs:
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
$fail = 0
|
||||
foreach ($t in 'onlaytest', 'keytest', 'a11ytest', 'animtest', 'localetest', 'laytest', 'texttest', 'csstest') {
|
||||
foreach ($t in Get-Content tools/ci/tests.txt) {
|
||||
Write-Host "== $t"
|
||||
& "./${{ matrix.out }}/$t.exe"
|
||||
if ($LASTEXITCODE -ne 0) { Write-Host "${t}: exit status $LASTEXITCODE"; $fail = 1 }
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
[submodule "external/SDL"]
|
||||
path = external/SDL
|
||||
url = https://github.com/libsdl-org/SDL.git
|
||||
[submodule "external/lcui"]
|
||||
path = external/lcui
|
||||
url = https://github.com/lc-soft/LCUI.git
|
||||
[submodule "external/onlay"]
|
||||
path = external/onlay
|
||||
url = https://github.com/Alpaq92/Onlay.git
|
||||
|
||||
@@ -5,7 +5,7 @@ C99. Widgets are declared; the look comes from CSS read at runtime.
|
||||
## Build and run
|
||||
|
||||
`./build.ps1` on Windows, `./build.sh` elsewhere — `cmake` is not on PATH, the
|
||||
script finds MSVC's. `./build.ps1 <target>` builds one. Targets: `showcase`,
|
||||
script finds MSVC's. `./build.ps1 <target>` or `./build.sh <target>` builds one. Targets: `showcase`,
|
||||
`notepad`, `simple`, `bench`, plus the tests in `tests/`. `-Arch x86` (or
|
||||
`arm64`) builds that architecture into `build-<arch>`; ARM64 needs Visual
|
||||
Studio's ARM64 tools, which this machine lacks, so CI is its only check.
|
||||
@@ -44,9 +44,10 @@ regression oracle for every layout or style change.
|
||||
only when it crosses a rectangle `hot_push` registered the frame before, so a
|
||||
widget that looks different under the pointer and registers none keeps its
|
||||
old look until some other input.
|
||||
- **libcss has no `em`/`rem`** — its units are px, %, dip, sp, pt. `cssflat.c`
|
||||
converts before the engine sees the text, along with `var()`, `color-mix()`,
|
||||
`@media` and attribute selectors.
|
||||
- **A percentage is not a length to the CSS engine.** `core/css/css.c` has no
|
||||
box to resolve one against, so `width: 100%` is dropped and a lower rule's
|
||||
value shows through. An attribute selector reads as a class: `[type=range]`
|
||||
answers `input.type-range`.
|
||||
- **The renderer snaps every vertex to whole pixels.** Sub-pixel corrections
|
||||
are discarded, and rects that abut can round apart into a visible seam.
|
||||
- **SDL redraws a software rectangle its own way.** Its software renderer
|
||||
|
||||
+20
-110
@@ -62,6 +62,17 @@ if(NOT MSVC AND NOT EMSCRIPTEN)
|
||||
endif()
|
||||
add_subdirectory("${TP}/SDL" EXCLUDE_FROM_ALL)
|
||||
|
||||
function(reaktor_write_if_changed path content)
|
||||
set(_old "")
|
||||
if(EXISTS "${path}")
|
||||
file(READ "${path}" _old)
|
||||
endif()
|
||||
if(NOT _old STREQUAL content)
|
||||
file(WRITE "${path}" "${content}")
|
||||
endif()
|
||||
endfunction()
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
# SDL's dynamic API keeps every SDL function linked and loads whichever SDL
|
||||
# library the SDL3_DYNAMIC_API environment variable names. Reaktor links SDL
|
||||
# statically and reads no environment, so it is compiled out.
|
||||
@@ -78,46 +89,6 @@ else()
|
||||
-include "${CMAKE_CURRENT_SOURCE_DIR}/core/sdl/no_dynapi.h")
|
||||
endif()
|
||||
|
||||
set(LC "${TP}/lcui/lib")
|
||||
set(LCUI_CFG "${CMAKE_BINARY_DIR}/gen/lcui")
|
||||
file(MAKE_DIRECTORY "${LCUI_CFG}")
|
||||
|
||||
set(LCUI_FEATURES YUTIL_STATIC_BUILD LIBCSS_STATIC_BUILD)
|
||||
|
||||
function(lcui_expand IN OUTVAR)
|
||||
file(READ "${IN}" _c)
|
||||
string(REGEX MATCHALL "\\$\\{define [A-Z_]+\\}" _tokens "${_c}")
|
||||
foreach(_t IN LISTS _tokens)
|
||||
string(REGEX REPLACE "\\$\\{define ([A-Z_]+)\\}" "\\1" _name "${_t}")
|
||||
list(FIND LCUI_FEATURES "${_name}" _found)
|
||||
if(_found GREATER -1)
|
||||
set(_r "#define ${_name} 1")
|
||||
else()
|
||||
set(_r "/* ${_name}: not enabled by this build */")
|
||||
endif()
|
||||
string(REPLACE "${_t}" "${_r}" _c "${_c}")
|
||||
endforeach()
|
||||
string(REPLACE "\${VERSION_MAJOR}" "0" _c "${_c}")
|
||||
string(REPLACE "\${VERSION_MINOR}" "0" _c "${_c}")
|
||||
string(REPLACE "\${VERSION_ALTER}" "0" _c "${_c}")
|
||||
string(REPLACE "\${VERSION}" "vendored" _c "${_c}")
|
||||
set(${OUTVAR} "${_c}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(LCUI_MERGED "/* Generated by CMakeLists.txt from the .in templates in\n external/lcui. Do not edit; do not commit. */\n")
|
||||
foreach(_in "${LC}/yutil/include/yutil/config.h.in"
|
||||
"${LC}/css/src/config.h.in")
|
||||
lcui_expand("${_in}" _part)
|
||||
string(APPEND LCUI_MERGED "\n${_part}")
|
||||
endforeach()
|
||||
set(_old "")
|
||||
if(EXISTS "${LCUI_CFG}/config.h")
|
||||
file(READ "${LCUI_CFG}/config.h" _old)
|
||||
endif()
|
||||
if(NOT _old STREQUAL LCUI_MERGED)
|
||||
file(WRITE "${LCUI_CFG}/config.h" "${LCUI_MERGED}")
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT EMSCRIPTEN)
|
||||
find_library(REAKTOR_LIBM m)
|
||||
if(REAKTOR_LIBM)
|
||||
@@ -125,20 +96,6 @@ if(UNIX AND NOT EMSCRIPTEN)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE LCUI_SRC
|
||||
"${LC}/yutil/src/*.c"
|
||||
"${LC}/css/src/*.c")
|
||||
|
||||
add_library(lcui STATIC ${LCUI_SRC})
|
||||
target_include_directories(lcui PUBLIC
|
||||
"${LCUI_CFG}"
|
||||
"${LC}/yutil/include"
|
||||
"${LC}/css/include")
|
||||
if(MSVC)
|
||||
target_compile_options(lcui PRIVATE /w)
|
||||
target_compile_definitions(lcui PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
file(GLOB PLUTOVG_SRC "${TP}/plutosvg/plutovg/source/*.c")
|
||||
add_library(plutovg STATIC ${PLUTOVG_SRC})
|
||||
target_include_directories(plutovg PUBLIC "${TP}/plutosvg/plutovg/include")
|
||||
@@ -167,8 +124,6 @@ target_compile_definitions(onlay PUBLIC LAY_FLOAT=1)
|
||||
if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
add_executable(onlaytest ${TP}/onlay/test_onlay.c)
|
||||
target_link_libraries(onlaytest PRIVATE onlay)
|
||||
set_target_properties(onlaytest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
set(REAKTOR_BUILTINS
|
||||
@@ -213,13 +168,7 @@ string(APPEND _gen
|
||||
"\nconst reaktor_builtin reaktor_builtins[] = {\n${_rows}};\n"
|
||||
"const int reaktor_builtin_count = ${_n};\n")
|
||||
set(_builtins "${CMAKE_BINARY_DIR}/gen/reaktor_builtins.c")
|
||||
set(_old "")
|
||||
if(EXISTS "${_builtins}")
|
||||
file(READ "${_builtins}" _old)
|
||||
endif()
|
||||
if(NOT _old STREQUAL _gen)
|
||||
file(WRITE "${_builtins}" "${_gen}")
|
||||
endif()
|
||||
reaktor_write_if_changed("${_builtins}" "${_gen}")
|
||||
message(STATUS "assets: ${_n} compiled in")
|
||||
|
||||
add_library(reaktor_headers INTERFACE)
|
||||
@@ -241,35 +190,23 @@ set(APP_RESOURCES "")
|
||||
|
||||
add_executable(mkicon EXCLUDE_FROM_ALL tools/mkicon.c)
|
||||
target_link_libraries(mkicon PRIVATE reaktor_core)
|
||||
set_target_properties(mkicon PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
add_executable(keytest tests/keytest.c core/ui/keys.c)
|
||||
target_link_libraries(keytest PRIVATE reaktor_headers)
|
||||
target_include_directories(keytest PRIVATE core/ui)
|
||||
target_link_libraries(keytest PRIVATE SDL3::SDL3-static)
|
||||
set_target_properties(keytest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
add_executable(a11ytest tests/a11ytest.c core/a11y/a11y.c
|
||||
platform/a11y/a11y_snapshot.c core/base/utf8.c)
|
||||
target_link_libraries(a11ytest PRIVATE reaktor_headers SDL3::SDL3-static)
|
||||
target_include_directories(a11ytest PRIVATE core/a11y core/render
|
||||
platform/a11y core/base)
|
||||
set_target_properties(a11ytest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
add_executable(animtest tests/animtest.c core/anim/anim.c)
|
||||
target_include_directories(animtest PRIVATE core/anim core/render
|
||||
"${TP}/nuklear/demo/sdl3_renderer")
|
||||
target_link_libraries(animtest PRIVATE reaktor_core SDL3::SDL3-static)
|
||||
set_target_properties(animtest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
add_executable(localetest tests/localetest.c
|
||||
core/locale/locale.c core/locale/plural.c
|
||||
@@ -277,34 +214,24 @@ if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
target_link_libraries(localetest PRIVATE reaktor_headers SDL3::SDL3-static)
|
||||
target_include_directories(localetest PRIVATE core/locale)
|
||||
target_compile_definitions(localetest PRIVATE REAKTOR_LOCALE_EMBEDDED)
|
||||
set_target_properties(localetest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
add_executable(laytest tests/laytest.c core/ui/layout.c)
|
||||
target_link_libraries(laytest PRIVATE reaktor_headers)
|
||||
target_include_directories(laytest PRIVATE core/ui core/render)
|
||||
target_link_libraries(laytest PRIVATE onlay)
|
||||
set_target_properties(laytest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
add_executable(csstest tests/csstest.c core/css/cssflat.c)
|
||||
add_executable(csstest tests/csstest.c core/css/css.c)
|
||||
target_include_directories(csstest PRIVATE core/css core/base)
|
||||
target_link_libraries(csstest PRIVATE plutovg)
|
||||
target_link_libraries(csstest PRIVATE plutovg reaktor_headers)
|
||||
target_compile_definitions(csstest PRIVATE _CRT_SECURE_NO_WARNINGS
|
||||
CSSTEST_SOURCE="${CMAKE_CURRENT_SOURCE_DIR}/")
|
||||
set_target_properties(csstest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
add_executable(basetest tests/basetest.c core/base/url.c core/base/utf8.c)
|
||||
target_include_directories(basetest PRIVATE core/base)
|
||||
target_link_libraries(basetest PRIVATE SDL3::SDL3-static)
|
||||
set_target_properties(basetest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
add_executable(imagetest tests/imagetest.c)
|
||||
target_link_libraries(imagetest PRIVATE plutovg)
|
||||
set_target_properties(imagetest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT EMSCRIPTEN)
|
||||
@@ -316,14 +243,7 @@ if(WIN32)
|
||||
file(MAKE_DIRECTORY "${GEN}")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${APP_ICON}"
|
||||
"${GEN}/reaktor.ico" COPYONLY)
|
||||
set(_rc "1 ICON \"reaktor.ico\"\n")
|
||||
set(_old "")
|
||||
if(EXISTS "${GEN}/reaktor.rc")
|
||||
file(READ "${GEN}/reaktor.rc" _old)
|
||||
endif()
|
||||
if(NOT _old STREQUAL _rc)
|
||||
file(WRITE "${GEN}/reaktor.rc" "${_rc}")
|
||||
endif()
|
||||
reaktor_write_if_changed("${GEN}/reaktor.rc" "1 ICON \"reaktor.ico\"\n")
|
||||
set(APP_RESOURCES "${GEN}/reaktor.rc")
|
||||
elseif(UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/reaktor.desktop"
|
||||
@@ -425,13 +345,7 @@ else()
|
||||
"\nconst struct reaktor_locale_catalog reaktor_locale_catalogs[] = {\n${_rows}};\n"
|
||||
"const int reaktor_locale_catalog_count = ${_n};\n")
|
||||
set(_out "${CMAKE_BINARY_DIR}/gen/locale_catalogs.c")
|
||||
set(_old "")
|
||||
if(EXISTS "${_out}")
|
||||
file(READ "${_out}" _old)
|
||||
endif()
|
||||
if(NOT _old STREQUAL _gen)
|
||||
file(WRITE "${_out}" "${_gen}")
|
||||
endif()
|
||||
reaktor_write_if_changed("${_out}" "${_gen}")
|
||||
target_sources(reaktor_locale INTERFACE "${_out}")
|
||||
target_compile_definitions(reaktor_locale INTERFACE REAKTOR_LOCALE_EMBEDDED)
|
||||
message(STATUS "locale: ${_n} catalogs compiled in")
|
||||
@@ -478,8 +392,6 @@ else()
|
||||
target_include_directories(texttest PRIVATE core/render core/text)
|
||||
target_link_libraries(texttest PRIVATE reaktor_text reaktor_core
|
||||
SDL3::SDL3-static)
|
||||
set_target_properties(texttest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -577,7 +489,7 @@ add_library(reaktor_runtime STATIC
|
||||
core/anim/anim.c
|
||||
core/base/metrics.c
|
||||
core/css/style.c
|
||||
core/css/cssflat.c
|
||||
core/css/css.c
|
||||
core/render/draw.c
|
||||
core/ui/declare.c
|
||||
core/ui/controls.c
|
||||
@@ -626,8 +538,7 @@ target_include_directories(reaktor_runtime PUBLIC
|
||||
target_link_libraries(reaktor_runtime PUBLIC
|
||||
reaktor_core
|
||||
SDL3::SDL3-static
|
||||
onlay
|
||||
lcui)
|
||||
onlay)
|
||||
|
||||
if(WIN32 AND NOT EMSCRIPTEN)
|
||||
target_link_libraries(reaktor_runtime PUBLIC dxguid)
|
||||
@@ -635,7 +546,7 @@ endif()
|
||||
|
||||
set(REAKTOR_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "")
|
||||
|
||||
foreach(_lic SDL/LICENSE.txt lcui/LICENSE.TXT plutosvg/LICENSE nuklear/LICENSE
|
||||
foreach(_lic SDL/LICENSE.txt plutosvg/LICENSE nuklear/LICENSE
|
||||
nukanim/LICENSE onlay/LICENSE watercss/LICENSE.md ionicons/LICENSE mojibake/LICENSE
|
||||
kb/LICENSE)
|
||||
string(REGEX REPLACE "/.*" "" _who "${_lic}")
|
||||
@@ -741,7 +652,6 @@ endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
target_compile_options(reaktor_runtime PRIVATE -Oz)
|
||||
target_compile_options(lcui PRIVATE -Oz)
|
||||
target_compile_options(plutovg PRIVATE -Oz)
|
||||
target_compile_options(plutosvg PRIVATE -Oz)
|
||||
target_compile_options(freetype PRIVATE -Oz)
|
||||
@@ -885,7 +795,7 @@ target_link_libraries(reaktor_modules PRIVATE reaktor_runtime reaktor_a11y reakt
|
||||
reaktor_inspector)
|
||||
set_target_properties(reaktor_modules PROPERTIES EXCLUDE_FROM_ALL ON)
|
||||
|
||||
set(_parts reaktor_runtime reaktor_core reaktor_modules plutosvg plutovg freetype lcui onlay
|
||||
set(_parts reaktor_runtime reaktor_core reaktor_modules plutosvg plutovg freetype onlay
|
||||
SDL3-static)
|
||||
foreach(_t mojibake_lib kb_text_shape)
|
||||
if(TARGET ${_t})
|
||||
|
||||
@@ -120,8 +120,8 @@ value and position.
|
||||
|
||||
[Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) draws the widgets.
|
||||
[SDL3](https://github.com/libsdl-org/SDL) supplies the window, input, tray and
|
||||
software renderer. libcss, from [LCUI](https://github.com/lc-soft/LCUI), parses
|
||||
the stylesheets, and [Onlay](https://github.com/Alpaq92/Onlay), a fork of
|
||||
software renderer. Reaktor's own CSS engine reads the stylesheets, and
|
||||
[Onlay](https://github.com/Alpaq92/Onlay), a fork of
|
||||
[randrew/layout](https://github.com/randrew/layout), computes the rectangles.
|
||||
[NukAnim](https://github.com/Alpaq92/NukAnim), a port of ImAnim, moves them.
|
||||
Every dependency is a submodule, used as it ships; the full list is in
|
||||
|
||||
@@ -85,9 +85,11 @@ Each arm uses its framework's own toolchain; none is vendored here.
|
||||
```bash
|
||||
cd benchmarks/electron-bench
|
||||
npm install
|
||||
npx install-electron
|
||||
```
|
||||
|
||||
Node 20.19+ or 22+; older Node fails with `ERR_REQUIRE_ESM`. `--software`
|
||||
Node 20.19+ or 22+; older Node fails with `ERR_REQUIRE_ESM`. Since Electron 44
|
||||
`npm install` no longer fetches the binary; `install-electron` does. `--software`
|
||||
turns hardware acceleration off.
|
||||
|
||||
### Flutter
|
||||
@@ -148,14 +150,14 @@ MSVC 14.44 Release, the C runtime linked in:
|
||||
|
||||
| Program | Bytes |
|
||||
| --- | --- |
|
||||
| `bench.exe` | 2,752,512 |
|
||||
| `simple.exe` | 2,760,192 |
|
||||
| `notepad.exe` | 2,797,568 |
|
||||
| `showcase.exe` | 3,782,656 |
|
||||
| `bench.exe` | 2,395,136 |
|
||||
| `simple.exe` | 2,404,864 |
|
||||
| `notepad.exe` | 2,518,016 |
|
||||
| `showcase.exe` | 3,585,536 |
|
||||
|
||||
The C runtime is about 300 KB of each; a default `./build.ps1` links its DLL
|
||||
The C runtime is 220–260 KB of each; a default `./build.ps1` links its DLL
|
||||
instead. Only the showcase links the three optional modules, and Text is
|
||||
0.8 MB of the difference ([Modules](../docs/PERFORMANCE.md#modules)).
|
||||
0.7 MB of the difference ([Modules](../docs/PERFORMANCE.md#modules)).
|
||||
|
||||
The v0.2.0 downloads, as GitHub Actions built and published them:
|
||||
|
||||
|
||||
+3
-2
@@ -6,7 +6,6 @@ $root = $PSScriptRoot
|
||||
$outDir = Join-Path $root "build-wasm"
|
||||
|
||||
$emsdk = if ($env:EMSDK) { $env:EMSDK } else { "$env:USERPROFILE\emsdk" }
|
||||
$emcc = Join-Path $emsdk "upstream\emscripten\emcc.py"
|
||||
$toolchain = Join-Path $emsdk "upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake"
|
||||
if (-not (Test-Path $toolchain)) {
|
||||
throw "emsdk not found at $emsdk - clone https://github.com/emscripten-core/emsdk, run 'emsdk install latest' then 'emsdk activate latest', or set EMSDK"
|
||||
@@ -47,5 +46,7 @@ Write-Host "a file:// page cannot fetch the .wasm, so serve it:"
|
||||
Write-Host " python -m http.server -d build-wasm 8000"
|
||||
|
||||
if ($Serve) {
|
||||
& (Join-Path $emsdk "python\3.13.3_64bit\python.exe") -m http.server -d $outDir 8000
|
||||
$python = Get-ChildItem (Join-Path $emsdk "python") -Filter python.exe -Recurse -Depth 1 |
|
||||
Sort-Object FullName | Select-Object -Last 1
|
||||
& $python.FullName -m http.server -d $outDir 8000
|
||||
}
|
||||
|
||||
@@ -14,9 +14,10 @@ while [ $# -gt 0 ]; do
|
||||
target="$1" ;;
|
||||
--debug) buildtype="Debug" ;;
|
||||
--release) buildtype="Release" ;;
|
||||
--help|-h) echo "usage: build.sh [--target NAME] [--debug] [-- CMAKE_ARGS]"; exit 0 ;;
|
||||
--help|-h) echo "usage: build.sh [NAME | --target NAME] [--debug] [-- CMAKE_ARGS]"; exit 0 ;;
|
||||
--) shift; break ;;
|
||||
*) echo "build.sh: unknown argument: $1 (try --help)" >&2; exit 2 ;;
|
||||
-*) echo "build.sh: unknown argument: $1 (try --help)" >&2; exit 2 ;;
|
||||
*) target="$1" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
+20
-33
@@ -55,13 +55,14 @@ intern(reaktor_a11y *a, const char *s, unsigned h)
|
||||
#define same_str(x, y) ((x) == (y) || ((x) && (y) && strcmp((x), (y)) == 0))
|
||||
|
||||
static reaktor_a11y_slot *
|
||||
slot_of(reaktor_a11y_slot *tab, unsigned gen, unsigned key)
|
||||
probe(reaktor_a11y_slot *tab, unsigned gen, unsigned key, int claim)
|
||||
{
|
||||
unsigned i = key & (REAKTOR_A11Y_SLOTS - 1), n;
|
||||
|
||||
for (n = 0; n < REAKTOR_A11Y_SLOTS; n++) {
|
||||
reaktor_a11y_slot *sl = &tab[i];
|
||||
if (sl->gen != gen) {
|
||||
if (!claim) return NULL;
|
||||
sl->gen = gen;
|
||||
sl->key = key;
|
||||
sl->val = 0;
|
||||
@@ -74,17 +75,11 @@ slot_of(reaktor_a11y_slot *tab, unsigned gen, unsigned key)
|
||||
}
|
||||
|
||||
static int
|
||||
slot_get(const reaktor_a11y_slot *tab, unsigned gen, unsigned key)
|
||||
slot_get(reaktor_a11y_slot *tab, unsigned gen, unsigned key)
|
||||
{
|
||||
unsigned i = key & (REAKTOR_A11Y_SLOTS - 1), n;
|
||||
const reaktor_a11y_slot *sl = probe(tab, gen, key, 0);
|
||||
|
||||
for (n = 0; n < REAKTOR_A11Y_SLOTS; n++) {
|
||||
const reaktor_a11y_slot *sl = &tab[i];
|
||||
if (sl->gen != gen) return 0;
|
||||
if (sl->key == key) return sl->val;
|
||||
i = (i + 1) & (REAKTOR_A11Y_SLOTS - 1);
|
||||
}
|
||||
return 0;
|
||||
return sl ? sl->val : 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -93,9 +88,9 @@ same_rect(struct nk_rect x, struct nk_rect y)
|
||||
return x.x == y.x && x.y == y.y && x.w == y.w && x.h == y.h;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
emit(reaktor_a11y *a, unsigned char role, const char *name, const char *value,
|
||||
unsigned state, struct nk_rect bounds)
|
||||
unsigned
|
||||
reaktor_a11y_add(reaktor_a11y *a, unsigned char role, const char *name,
|
||||
const char *value, unsigned state, struct nk_rect bounds)
|
||||
{
|
||||
int f = a->front;
|
||||
reaktor_a11y_node *n;
|
||||
@@ -114,7 +109,7 @@ emit(reaktor_a11y *a, unsigned char role, const char *name, const char *value,
|
||||
base = nh ^ ((unsigned)role * 0x9e3779b9u);
|
||||
base ^= parent + 0x9e3779b9u + (base << 6) + (base >> 2);
|
||||
|
||||
sl = slot_of(a->bucket, a->bucket_gen, base);
|
||||
sl = probe(a->bucket, a->bucket_gen, base, 1);
|
||||
id = sl ? base ^ ((unsigned)sl->val++ * 0x85ebca6bu) : base;
|
||||
if (id == 0) id = 1;
|
||||
|
||||
@@ -217,18 +212,11 @@ reaktor_a11y_begin(reaktor_a11y *a, const char *window_name,
|
||||
reaktor_a11y_push(a, REAKTOR_A11Y_WINDOW, window_name, NULL, 0, bounds);
|
||||
}
|
||||
|
||||
unsigned
|
||||
reaktor_a11y_add(reaktor_a11y *a, unsigned char role, const char *name,
|
||||
const char *value, unsigned state, struct nk_rect bounds)
|
||||
{
|
||||
return emit(a, role, name, value, state, bounds);
|
||||
}
|
||||
|
||||
unsigned
|
||||
reaktor_a11y_push(reaktor_a11y *a, unsigned char role, const char *name,
|
||||
const char *value, unsigned state, struct nk_rect bounds)
|
||||
{
|
||||
unsigned id = emit(a, role, name, value, state, bounds);
|
||||
unsigned id = reaktor_a11y_add(a, role, name, value, state, bounds);
|
||||
|
||||
if (a->depth < REAKTOR_A11Y_MAX_DEPTH)
|
||||
a->parent[a->depth] = id;
|
||||
@@ -243,12 +231,11 @@ reaktor_a11y_pop(reaktor_a11y *a)
|
||||
}
|
||||
|
||||
static void
|
||||
change(reaktor_a11y *a, unsigned char kind, unsigned id, int index)
|
||||
change(reaktor_a11y *a, unsigned char kind, unsigned id)
|
||||
{
|
||||
if (a->change_count >= REAKTOR_A11Y_MAX_CHANGES) return;
|
||||
a->change[a->change_count].kind = kind;
|
||||
a->change[a->change_count].id = id;
|
||||
a->change[a->change_count].index = index;
|
||||
a->change[a->change_count].kind = kind;
|
||||
a->change[a->change_count].id = id;
|
||||
a->change_count++;
|
||||
}
|
||||
|
||||
@@ -267,7 +254,7 @@ reaktor_a11y_end(reaktor_a11y *a)
|
||||
|
||||
a->index_gen++;
|
||||
for (i = 0; i < ncur; i++)
|
||||
if ((sl = slot_of(a->index, a->index_gen, cur[i].id))) sl->val = i + 1;
|
||||
if ((sl = probe(a->index, a->index_gen, cur[i].id, 1))) sl->val = i + 1;
|
||||
|
||||
for (i = 1; i < ncur; i++) {
|
||||
struct nk_rect b = cur[i].bounds;
|
||||
@@ -291,7 +278,7 @@ reaktor_a11y_end(reaktor_a11y *a)
|
||||
|
||||
a->index_gen++;
|
||||
for (i = 0; i < nold; i++)
|
||||
if ((sl = slot_of(a->index, a->index_gen, old[i].id))) sl->val = i + 1;
|
||||
if ((sl = probe(a->index, a->index_gen, old[i].id, 1))) sl->val = i + 1;
|
||||
if (nold > 0) memset(a->matched, 0, (size_t)nold);
|
||||
|
||||
for (i = 0; i < ncur; i++) {
|
||||
@@ -299,18 +286,18 @@ reaktor_a11y_end(reaktor_a11y *a)
|
||||
if (j < 0) {
|
||||
if (!cur[i].parent ||
|
||||
slot_get(a->index, a->index_gen, cur[i].parent) > 0)
|
||||
change(a, REAKTOR_A11Y_ADDED, cur[i].id, i);
|
||||
change(a, REAKTOR_A11Y_ADDED, cur[i].id);
|
||||
continue;
|
||||
}
|
||||
a->matched[j] = 1;
|
||||
if (!same_str(cur[i].name, old[j].name) ||
|
||||
!same_str(cur[i].value, old[j].value) ||
|
||||
!same_str(cur[i].keys, old[j].keys))
|
||||
change(a, REAKTOR_A11Y_RENAMED, cur[i].id, i);
|
||||
change(a, REAKTOR_A11Y_RENAMED, cur[i].id);
|
||||
if (cur[i].state != old[j].state)
|
||||
change(a, REAKTOR_A11Y_RESTATED, cur[i].id, i);
|
||||
change(a, REAKTOR_A11Y_RESTATED, cur[i].id);
|
||||
else if (!same_rect(cur[i].bounds, old[j].bounds))
|
||||
change(a, REAKTOR_A11Y_MOVED, cur[i].id, i);
|
||||
change(a, REAKTOR_A11Y_MOVED, cur[i].id);
|
||||
}
|
||||
for (i = 0; i < nold; i++) {
|
||||
if (a->matched[i]) continue;
|
||||
@@ -318,7 +305,7 @@ reaktor_a11y_end(reaktor_a11y *a)
|
||||
int up = slot_get(a->index, a->index_gen, old[i].parent) - 1;
|
||||
if (up >= 0 && !a->matched[up]) continue;
|
||||
}
|
||||
change(a, REAKTOR_A11Y_REMOVED, old[i].id, i);
|
||||
change(a, REAKTOR_A11Y_REMOVED, old[i].id);
|
||||
}
|
||||
|
||||
a->front = b;
|
||||
|
||||
@@ -29,7 +29,6 @@ enum {
|
||||
typedef struct reaktor_a11y_change {
|
||||
unsigned char kind;
|
||||
unsigned id;
|
||||
int index;
|
||||
} reaktor_a11y_change;
|
||||
|
||||
#define REAKTOR_A11Y_MAX_NODES 256
|
||||
|
||||
@@ -133,6 +133,30 @@ int reaktor_path_absolute(const char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int reaktor_grow(void **p, int *cap, int need, size_t size)
|
||||
{
|
||||
int n = *cap > 0 ? *cap : 64;
|
||||
void *q;
|
||||
|
||||
if (need <= *cap) return 1;
|
||||
while (n < need) n *= 2;
|
||||
if (!(q = SDL_realloc(*p, (size_t)n * size))) return 0;
|
||||
*p = q;
|
||||
*cap = n;
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *reaktor_path_from_cwd(const char *path)
|
||||
{
|
||||
char *cwd, *out = NULL;
|
||||
|
||||
if (reaktor_path_absolute(path)) return SDL_strdup(path);
|
||||
if (!(cwd = SDL_GetCurrentDirectory())) return NULL;
|
||||
if (SDL_asprintf(&out, "%s%s", cwd, path) < 0) out = NULL;
|
||||
SDL_free(cwd);
|
||||
return out;
|
||||
}
|
||||
|
||||
const char *reaktor_path_leaf(const char *path)
|
||||
{
|
||||
const char *p, *leaf = path;
|
||||
|
||||
+2
-2
@@ -11,6 +11,8 @@ char *reaktor_read_file(const char *path, size_t *len);
|
||||
FILE *reaktor_fopen(const char *path, const char *mode);
|
||||
|
||||
int reaktor_path_absolute(const char *path);
|
||||
char *reaktor_path_from_cwd(const char *path);
|
||||
int reaktor_grow(void **p, int *cap, int need, size_t size);
|
||||
const char *reaktor_path_leaf(const char *path);
|
||||
|
||||
char *reaktor_c_locale_keep(int numeric);
|
||||
@@ -57,6 +59,4 @@ reaktor_fnv_n(unsigned h, const void *p, size_t n)
|
||||
return h;
|
||||
}
|
||||
|
||||
#define REAKTOR_MARK "assets/icons/reaktor-icon.svg"
|
||||
|
||||
#endif
|
||||
|
||||
+1680
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
#ifndef REAKTOR_CSS_H
|
||||
#define REAKTOR_CSS_H
|
||||
|
||||
#include "reaktor/style.h"
|
||||
|
||||
typedef struct reaktor_sheet reaktor_sheet;
|
||||
|
||||
reaktor_sheet *reaktor_sheet_load(const char *const *paths, int count, const char *theme);
|
||||
void reaktor_sheet_free(reaktor_sheet *s);
|
||||
void reaktor_sheet_style(const reaktor_sheet *s, const char *selector, reaktor_style *out);
|
||||
int reaktor_sheet_color(const reaktor_sheet *s, const char *name, unsigned char rgba[4]);
|
||||
|
||||
/* What @media (prefers-reduced-motion) and (prefers-contrast) answer. */
|
||||
void reaktor_css_media(int reduce_motion, int more_contrast);
|
||||
|
||||
/* Told each sheet a load reads, @imports too, as the sheet names it. */
|
||||
void reaktor_css_track(void (*seen)(const char *path));
|
||||
|
||||
#endif
|
||||
-1419
File diff suppressed because it is too large
Load Diff
@@ -1,23 +0,0 @@
|
||||
#ifndef REAKTOR_CSSFLAT_H
|
||||
#define REAKTOR_CSSFLAT_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct reaktor_cssvars reaktor_cssvars;
|
||||
|
||||
/* A declaration or selector of token_max bytes or more is dropped; 0 keeps all. */
|
||||
char *reaktor_css_flatten(const char *const *paths, int count, const char *theme,
|
||||
size_t token_max, reaktor_cssvars **out_vars);
|
||||
|
||||
/* What @media (prefers-reduced-motion) and (prefers-contrast) answer. */
|
||||
void reaktor_css_media(int reduce_motion, int more_contrast);
|
||||
|
||||
/* Told each sheet a flatten reads, @imports too, as the sheet names it. */
|
||||
void reaktor_css_track(void (*seen)(const char *path));
|
||||
|
||||
int reaktor_cssvars_color(const reaktor_cssvars *vars, const char *name,
|
||||
unsigned char rgba[4]);
|
||||
|
||||
void reaktor_cssvars_free(reaktor_cssvars *vars);
|
||||
|
||||
#endif
|
||||
+41
-260
@@ -1,14 +1,6 @@
|
||||
#include "style.h"
|
||||
#include "cssflat.h"
|
||||
#include "css.h"
|
||||
|
||||
#include <css.h>
|
||||
#include <css/parser.h>
|
||||
#include <css/library.h>
|
||||
#include <css/selector.h>
|
||||
#include <css/computed.h>
|
||||
#include <css/style_decl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -21,24 +13,12 @@ typedef struct cache_entry {
|
||||
} cache_entry;
|
||||
|
||||
static struct {
|
||||
int ready;
|
||||
reaktor_sheet *sheet;
|
||||
cache_entry *cache;
|
||||
unsigned cache_cap, cache_n;
|
||||
css_metrics_t metrics;
|
||||
reaktor_cssvars *vars;
|
||||
css_computed_style_t root;
|
||||
int root_ready;
|
||||
unsigned generation;
|
||||
} g;
|
||||
|
||||
static void rgba_of(css_color_value_t c, unsigned char out[4])
|
||||
{
|
||||
out[0] = (unsigned char)((c >> 16) & 0xff);
|
||||
out[1] = (unsigned char)((c >> 8) & 0xff);
|
||||
out[2] = (unsigned char)(c & 0xff);
|
||||
out[3] = (unsigned char)((c >> 24) & 0xff);
|
||||
}
|
||||
|
||||
static void cache_clear(int release)
|
||||
{
|
||||
unsigned i;
|
||||
@@ -55,11 +35,6 @@ static void cache_clear(int release)
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned hash_of(const char *s)
|
||||
{
|
||||
return reaktor_fnv(REAKTOR_FNV, s);
|
||||
}
|
||||
|
||||
static cache_entry *cache_slot(const char *selector, unsigned h)
|
||||
{
|
||||
unsigned i = h & (g.cache_cap - 1);
|
||||
@@ -84,100 +59,23 @@ static void cache_grow(void)
|
||||
free(old);
|
||||
}
|
||||
|
||||
static void base_reset(void)
|
||||
{
|
||||
if (g.root_ready) css_computed_style_destroy(&g.root);
|
||||
memset(&g.root, 0, sizeof(g.root));
|
||||
g.root_ready = 0;
|
||||
}
|
||||
|
||||
static int style_load(const char *const *css_paths, int count,
|
||||
const char *theme)
|
||||
{
|
||||
char *flat;
|
||||
css_parser_t *parser;
|
||||
|
||||
if (!g.ready) {
|
||||
css_init();
|
||||
g.metrics.dpi = 96.0f;
|
||||
g.metrics.density = 1.0f;
|
||||
g.metrics.scaled_density = 1.0f;
|
||||
g.metrics.scale = 1.0f;
|
||||
g.ready = 1;
|
||||
} else {
|
||||
css_destroy_library();
|
||||
css_init_library();
|
||||
}
|
||||
cache_clear(0);
|
||||
g.generation++;
|
||||
base_reset();
|
||||
|
||||
reaktor_cssvars_free(g.vars);
|
||||
g.vars = NULL;
|
||||
/* The parser copies each token into a buffer this size without a bound. */
|
||||
flat = reaktor_css_flatten(css_paths, count, theme, CSS_PARSER_BUFFER_SIZE - 1,
|
||||
&g.vars);
|
||||
if (!flat) return 0;
|
||||
|
||||
parser = css_parser_create("reaktor");
|
||||
if (!parser) { free(flat); return 0; }
|
||||
{
|
||||
const char *cur = flat;
|
||||
size_t len = 1;
|
||||
while (len > 0) {
|
||||
len = css_parser_parse(parser, cur);
|
||||
cur += len;
|
||||
}
|
||||
}
|
||||
css_parser_destroy(parser);
|
||||
free(flat);
|
||||
|
||||
/* One cascade: a second resets the first and leaks its font_family. */
|
||||
base_reset();
|
||||
{
|
||||
static const css_computed_style_t none;
|
||||
css_selector_t *bs = css_selector_create("body");
|
||||
|
||||
if (bs) {
|
||||
css_style_decl_t *bd = css_select_style(bs);
|
||||
|
||||
css_selector_destroy(bs);
|
||||
if (bd) {
|
||||
css_cascade_style(bd, &g.root);
|
||||
css_style_decl_destroy(bd);
|
||||
}
|
||||
}
|
||||
css_compute_absolute_values(&none, &g.root, &g.metrics);
|
||||
}
|
||||
g.root_ready = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* libcss reads numbers with sscanf, which takes the locale's decimal mark. */
|
||||
int reaktor_style_init(const char *const *css_paths, int count,
|
||||
const char *theme)
|
||||
{
|
||||
char *was = reaktor_c_locale_keep(1);
|
||||
int ok;
|
||||
reaktor_sheet *sheet = reaktor_sheet_load(css_paths, count, theme);
|
||||
|
||||
reaktor_c_locale_put(1, NULL);
|
||||
ok = style_load(css_paths, count, theme);
|
||||
reaktor_c_locale_put(1, was);
|
||||
return ok;
|
||||
cache_clear(0);
|
||||
g.generation++;
|
||||
reaktor_sheet_free(g.sheet);
|
||||
g.sheet = sheet;
|
||||
return sheet != NULL;
|
||||
}
|
||||
|
||||
void reaktor_style_shutdown(void)
|
||||
{
|
||||
if (!g.ready) return;
|
||||
reaktor_cssvars_free(g.vars);
|
||||
g.vars = NULL;
|
||||
if (g.root_ready) {
|
||||
css_computed_style_destroy(&g.root);
|
||||
g.root_ready = 0;
|
||||
}
|
||||
css_destroy();
|
||||
g.ready = 0;
|
||||
cache_clear(1);
|
||||
reaktor_sheet_free(g.sheet);
|
||||
g.sheet = NULL;
|
||||
}
|
||||
|
||||
unsigned reaktor_style_loads(void)
|
||||
@@ -185,11 +83,6 @@ unsigned reaktor_style_loads(void)
|
||||
return g.generation;
|
||||
}
|
||||
|
||||
int reaktor_style_token(const char *name, unsigned char rgba[4])
|
||||
{
|
||||
return reaktor_cssvars_color(g.vars, name, rgba);
|
||||
}
|
||||
|
||||
void reaktor_style_darken(unsigned char rgba[4], float amount)
|
||||
{
|
||||
int i;
|
||||
@@ -200,158 +93,46 @@ void reaktor_style_darken(unsigned char rgba[4], float amount)
|
||||
rgba[i] = (unsigned char)(rgba[i] * (1.0f - amount) + 0.5f);
|
||||
}
|
||||
|
||||
static float px_of(css_numeric_value_t v, css_unit_t unit)
|
||||
/* Selectors and "--" tokens share the cache; a token keeps its color in bg. */
|
||||
static const reaktor_style *cached(const char *key)
|
||||
{
|
||||
return unit == CSS_UNIT_PX ? v : 0.0f;
|
||||
unsigned h = reaktor_fnv(REAKTOR_FNV, key);
|
||||
size_t len;
|
||||
cache_entry *e;
|
||||
|
||||
if (g.cache_cap && (e = cache_slot(key, h))->selector) return &e->style;
|
||||
if (2 * (g.cache_n + 1) > g.cache_cap) cache_grow();
|
||||
if (g.cache_n + 1 >= g.cache_cap) return NULL;
|
||||
len = strlen(key) + 1;
|
||||
e = cache_slot(key, h);
|
||||
if (!(e->selector = malloc(len))) return NULL;
|
||||
memcpy(e->selector, key, len);
|
||||
e->hash = h;
|
||||
if (key[0] == '-' && key[1] == '-') {
|
||||
memset(&e->style, 0, sizeof e->style);
|
||||
e->style.matched = reaktor_sheet_color(g.sheet, key, e->style.bg);
|
||||
} else {
|
||||
reaktor_sheet_style(g.sheet, key, &e->style);
|
||||
}
|
||||
g.cache_n++;
|
||||
return &e->style;
|
||||
}
|
||||
|
||||
static void resolve(const char *selector, reaktor_style *out)
|
||||
int reaktor_style_token(const char *name, unsigned char rgba[4])
|
||||
{
|
||||
css_selector_t *sel;
|
||||
css_style_decl_t *decl;
|
||||
css_computed_style_t computed;
|
||||
const reaktor_style *c;
|
||||
|
||||
memset(out, 0, sizeof(*out));
|
||||
out->opacity = 1.0f;
|
||||
if (!g.ready || !selector) return;
|
||||
|
||||
sel = css_selector_create(selector);
|
||||
if (!sel) return;
|
||||
|
||||
decl = css_select_style(sel);
|
||||
css_selector_destroy(sel);
|
||||
if (!decl) return;
|
||||
|
||||
memset(&computed, 0, sizeof(computed));
|
||||
css_cascade_style(decl, &computed);
|
||||
css_compute_absolute_values(&g.root, &computed, &g.metrics);
|
||||
|
||||
rgba_of(computed.background_color, out->bg);
|
||||
rgba_of(computed.color, out->fg);
|
||||
rgba_of(computed.border_top_color, out->border_col);
|
||||
out->border = px_of(computed.border_top_width,
|
||||
computed.unit_bits.border_top_width);
|
||||
out->rounding = px_of(computed.border_top_left_radius,
|
||||
computed.unit_bits.border_top_left_radius);
|
||||
out->pad_x = px_of(computed.padding_left,
|
||||
computed.unit_bits.padding_left);
|
||||
out->pad_y = px_of(computed.padding_top,
|
||||
computed.unit_bits.padding_top);
|
||||
|
||||
out->pad[REAKTOR_SIDE_TOP] = out->pad_y;
|
||||
out->pad[REAKTOR_SIDE_RIGHT] = px_of(computed.padding_right,
|
||||
computed.unit_bits.padding_right);
|
||||
out->pad[REAKTOR_SIDE_BOTTOM] = px_of(computed.padding_bottom,
|
||||
computed.unit_bits.padding_bottom);
|
||||
out->pad[REAKTOR_SIDE_LEFT] = out->pad_x;
|
||||
|
||||
out->border_w[REAKTOR_SIDE_TOP] = out->border;
|
||||
out->border_w[REAKTOR_SIDE_RIGHT] =
|
||||
px_of(computed.border_right_width,
|
||||
computed.unit_bits.border_right_width);
|
||||
out->border_w[REAKTOR_SIDE_BOTTOM] =
|
||||
px_of(computed.border_bottom_width,
|
||||
computed.unit_bits.border_bottom_width);
|
||||
out->border_w[REAKTOR_SIDE_LEFT] =
|
||||
px_of(computed.border_left_width,
|
||||
computed.unit_bits.border_left_width);
|
||||
|
||||
out->radius[REAKTOR_CORNER_TL] = out->rounding;
|
||||
out->radius[REAKTOR_CORNER_TR] =
|
||||
px_of(computed.border_top_right_radius,
|
||||
computed.unit_bits.border_top_right_radius);
|
||||
out->radius[REAKTOR_CORNER_BR] =
|
||||
px_of(computed.border_bottom_right_radius,
|
||||
computed.unit_bits.border_bottom_right_radius);
|
||||
out->radius[REAKTOR_CORNER_BL] =
|
||||
px_of(computed.border_bottom_left_radius,
|
||||
computed.unit_bits.border_bottom_left_radius);
|
||||
|
||||
out->margin[REAKTOR_SIDE_TOP] = px_of(computed.margin_top,
|
||||
computed.unit_bits.margin_top);
|
||||
out->margin[REAKTOR_SIDE_RIGHT] = px_of(computed.margin_right,
|
||||
computed.unit_bits.margin_right);
|
||||
out->margin[REAKTOR_SIDE_BOTTOM] =
|
||||
px_of(computed.margin_bottom, computed.unit_bits.margin_bottom);
|
||||
out->margin[REAKTOR_SIDE_LEFT] = px_of(computed.margin_left,
|
||||
computed.unit_bits.margin_left);
|
||||
|
||||
out->width = px_of(computed.width, computed.unit_bits.width);
|
||||
out->height = px_of(computed.height, computed.unit_bits.height);
|
||||
out->min_width = px_of(computed.min_width,
|
||||
computed.unit_bits.min_width);
|
||||
out->min_height = px_of(computed.min_height,
|
||||
computed.unit_bits.min_height);
|
||||
out->font_px = computed.font_size > 0.0f
|
||||
? (int)(computed.font_size + 0.5f) : 0;
|
||||
out->max_width = px_of(computed.max_width,
|
||||
computed.unit_bits.max_width);
|
||||
out->max_height = px_of(computed.max_height,
|
||||
computed.unit_bits.max_height);
|
||||
|
||||
out->opacity = computed.type_bits.opacity == CSS_OPACITY_SET
|
||||
? computed.opacity : 1.0f;
|
||||
if (out->opacity < 0.0f) out->opacity = 0.0f;
|
||||
if (out->opacity > 1.0f) out->opacity = 1.0f;
|
||||
|
||||
out->line_height = 0.0f;
|
||||
switch (computed.type_bits.line_height) {
|
||||
case CSS_LINE_HEIGHT_NUMBER: {
|
||||
float fs = computed.font_size > 0.0f ? computed.font_size
|
||||
: g.root.font_size;
|
||||
|
||||
out->line_height = computed.line_height * (fs > 0.0f ? fs : 16.0f);
|
||||
break;
|
||||
}
|
||||
case CSS_LINE_HEIGHT_DIMENSION:
|
||||
out->line_height = px_of(computed.line_height,
|
||||
computed.unit_bits.line_height);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (computed.type_bits.font_weight) {
|
||||
case CSS_FONT_WEIGHT_BOLD:
|
||||
case CSS_FONT_WEIGHT_700:
|
||||
case CSS_FONT_WEIGHT_800:
|
||||
case CSS_FONT_WEIGHT_900:
|
||||
out->bold = 1;
|
||||
break;
|
||||
default:
|
||||
out->bold = 0;
|
||||
break;
|
||||
}
|
||||
out->matched = decl->length > 0;
|
||||
|
||||
css_style_decl_destroy(decl);
|
||||
css_computed_style_destroy(&computed);
|
||||
if (!name || name[0] != '-' || name[1] != '-') return 0;
|
||||
if (!(c = cached(name))) return reaktor_sheet_color(g.sheet, name, rgba);
|
||||
if (c->matched) memcpy(rgba, c->bg, 4);
|
||||
return c->matched;
|
||||
}
|
||||
|
||||
void reaktor_style_get(const char *selector, reaktor_style *out)
|
||||
{
|
||||
unsigned h;
|
||||
size_t len;
|
||||
cache_entry *e;
|
||||
const reaktor_style *c;
|
||||
|
||||
if (!out) return;
|
||||
h = hash_of(selector);
|
||||
if (g.cache_cap) {
|
||||
e = cache_slot(selector, h);
|
||||
if (e->selector) {
|
||||
*out = e->style;
|
||||
return;
|
||||
}
|
||||
}
|
||||
resolve(selector, out);
|
||||
if (2 * (g.cache_n + 1) > g.cache_cap) cache_grow();
|
||||
if (g.cache_n + 1 >= g.cache_cap) return;
|
||||
len = strlen(selector) + 1;
|
||||
e = cache_slot(selector, h);
|
||||
e->selector = malloc(len);
|
||||
if (!e->selector) return;
|
||||
memcpy(e->selector, selector, len);
|
||||
e->hash = h;
|
||||
e->style = *out;
|
||||
g.cache_n++;
|
||||
if (selector && (c = cached(selector)) != NULL) *out = *c;
|
||||
else reaktor_sheet_style(g.sheet, selector, out);
|
||||
}
|
||||
|
||||
+2
-6
@@ -132,7 +132,7 @@ struct App {
|
||||
char tip_text[256];
|
||||
|
||||
char render_mode[32];
|
||||
int vsync_on, aa_mode, redraw_always;
|
||||
int vsync_on, aa_mode;
|
||||
|
||||
char frame_rate[16];
|
||||
char drag_rate[16];
|
||||
@@ -218,7 +218,6 @@ struct App {
|
||||
Uint64 last_draw_ms;
|
||||
int hover_pending;
|
||||
int renderer_is_sw;
|
||||
int sw_noaa;
|
||||
int drag_moved;
|
||||
int cal_frames, cal_done;
|
||||
double cal_cpu0;
|
||||
@@ -448,8 +447,6 @@ typedef struct reaktor_button_look {
|
||||
void reaktor_button_look_of(const char *selector, reaktor_button_look *k);
|
||||
int reaktor_css_button_look(App *app, struct nk_context *ctx,
|
||||
const reaktor_button_look *k, const char *label);
|
||||
int reaktor_button_label_as(App *app, struct nk_context *ctx,
|
||||
const char *sel, const char *label);
|
||||
int reaktor_button_accent_as(App *app, struct nk_context *ctx, const char *sel,
|
||||
const char *ionicon, const char *label);
|
||||
int reaktor_css_button_custom(App *app, struct nk_context *ctx, const char *sel,
|
||||
@@ -497,8 +494,7 @@ void reaktor_combo_chrome(App *app, struct nk_context *ctx, struct nk_rect h,
|
||||
|
||||
int reaktor_link_label(App *app, struct nk_context *ctx, const char *label,
|
||||
int active);
|
||||
int reaktor_css_button_color(App *app, struct nk_context *ctx, const char *name,
|
||||
struct nk_color fill);
|
||||
int reaktor_css_button_color(App *app, struct nk_context *ctx, struct nk_color fill);
|
||||
|
||||
void field_undo_clear(App *app);
|
||||
|
||||
|
||||
+1
-1
@@ -422,7 +422,7 @@ mask_rounded_fills(App *app)
|
||||
int
|
||||
reaktor_aa_lines(const App *app)
|
||||
{
|
||||
return app->aa_mode != REAKTOR_AA_OFF && !(app->renderer_is_sw && app->sw_noaa);
|
||||
return app->aa_mode != REAKTOR_AA_OFF;
|
||||
}
|
||||
|
||||
/* Left to a GPU renderer by default; rounded fills are masks either way. */
|
||||
|
||||
+3
-16
@@ -6,6 +6,7 @@
|
||||
#include FT_MODULE_H
|
||||
|
||||
#include "font.h"
|
||||
#include "util.h"
|
||||
|
||||
typedef struct baked {
|
||||
int w, h, left, top, at;
|
||||
@@ -237,20 +238,6 @@ pack(baked *b, int n, int *w, int *h)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
grow(void **p, int *cap, int need, size_t size)
|
||||
{
|
||||
int n = *cap > 0 ? *cap : 256;
|
||||
void *q;
|
||||
|
||||
if (need <= *cap) return 1;
|
||||
while (n < need) n *= 2;
|
||||
if (!(q = SDL_realloc(*p, (size_t)n * size))) return 0;
|
||||
*p = q;
|
||||
*cap = n;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_fontset_bake(struct reaktor_fontset *set, const struct reaktor_face_src *src,
|
||||
int n, const nk_rune *ranges)
|
||||
@@ -290,8 +277,8 @@ reaktor_fontset_bake(struct reaktor_fontset *set, const struct reaktor_face_src
|
||||
FT_Get_Advance(face, id, FT_LOAD_NO_SCALE, &adv))
|
||||
continue;
|
||||
bm = &face->glyph->bitmap;
|
||||
if (!grow((void **)&b, &cap_b, nb + 1, sizeof *b) ||
|
||||
!grow((void **)&bits, &cap_bits, used + (int)(bm->width * bm->rows), 1)) {
|
||||
if (!reaktor_grow((void **)&b, &cap_b, nb + 1, sizeof *b) ||
|
||||
!reaktor_grow((void **)&bits, &cap_bits, used + (int)(bm->width * bm->rows), 1)) {
|
||||
FT_Done_Face(face);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -34,10 +34,6 @@ extern "C"{
|
||||
#endif
|
||||
|
||||
NK_API struct nk_context* nk_sdl_init(SDL_Window *win, SDL_Renderer *renderer, struct nk_allocator allocator);
|
||||
#ifdef NK_INCLUDE_FONT_BAKING
|
||||
NK_API struct nk_font_atlas* nk_sdl_font_stash_begin(struct nk_context* ctx);
|
||||
NK_API void nk_sdl_font_stash_end(struct nk_context* ctx);
|
||||
#endif
|
||||
/* REAKTOR: an atlas Reaktor bakes itself, alpha8. */
|
||||
NK_API nk_handle nk_sdl_font_upload(struct nk_context* ctx, const void *image, int width, int height);
|
||||
NK_API int nk_sdl_handle_event(struct nk_context* ctx, SDL_Event *evt);
|
||||
@@ -90,9 +86,6 @@ struct nk_sdl {
|
||||
SDL_Renderer *renderer;
|
||||
struct nk_sdl_device ogl;
|
||||
struct nk_context ctx;
|
||||
#ifdef NK_INCLUDE_FONT_BAKING
|
||||
struct nk_font_atlas atlas;
|
||||
#endif
|
||||
struct nk_allocator allocator;
|
||||
Uint64 last_render;
|
||||
bool insert_toggle;
|
||||
@@ -646,38 +639,6 @@ nk_sdl_init(SDL_Window *win, SDL_Renderer *renderer, struct nk_allocator allocat
|
||||
return &sdl->ctx;
|
||||
}
|
||||
|
||||
#ifdef NK_INCLUDE_FONT_BAKING
|
||||
NK_API struct nk_font_atlas*
|
||||
nk_sdl_font_stash_begin(struct nk_context* ctx)
|
||||
{
|
||||
struct nk_sdl* sdl;
|
||||
NK_ASSERT(ctx);
|
||||
sdl = (struct nk_sdl*)ctx->userdata.ptr;
|
||||
NK_ASSERT(sdl);
|
||||
nk_font_atlas_init(&sdl->atlas, &sdl->allocator);
|
||||
nk_font_atlas_begin(&sdl->atlas);
|
||||
return &sdl->atlas;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NK_INCLUDE_FONT_BAKING
|
||||
NK_API void
|
||||
nk_sdl_font_stash_end(struct nk_context* ctx)
|
||||
{
|
||||
struct nk_sdl* sdl;
|
||||
const void *image; int w, h;
|
||||
NK_ASSERT(ctx);
|
||||
sdl = (struct nk_sdl*)ctx->userdata.ptr;
|
||||
NK_ASSERT(sdl);
|
||||
/* REAKTOR: alpha8. */
|
||||
image = nk_font_atlas_bake(&sdl->atlas, &w, &h, NK_FONT_ATLAS_ALPHA8);
|
||||
NK_ASSERT(image);
|
||||
nk_font_atlas_end(&sdl->atlas, nk_sdl_font_upload(&sdl->ctx, image, w, h), &sdl->ogl.tex_null);
|
||||
if (sdl->atlas.default_font) {
|
||||
nk_style_set_font(&sdl->ctx, &sdl->atlas.default_font->handle);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* REAKTOR */
|
||||
NK_API nk_handle
|
||||
@@ -862,11 +823,6 @@ void nk_sdl_shutdown(struct nk_context* ctx)
|
||||
sdl = (struct nk_sdl*)ctx->userdata.ptr;
|
||||
NK_ASSERT(sdl);
|
||||
|
||||
#ifdef NK_INCLUDE_FONT_BAKING
|
||||
if (sdl->atlas.font_num > 0)
|
||||
nk_font_atlas_clear(&sdl->atlas);
|
||||
#endif
|
||||
|
||||
nk_buffer_free(&sdl->ogl.cmds);
|
||||
nk_buffer_free(&sdl->ogl.vbuf);
|
||||
nk_buffer_free(&sdl->ogl.ebuf);
|
||||
|
||||
+9
-36
@@ -137,18 +137,6 @@ static int g_draws, g_draw_cap;
|
||||
static unsigned g_seq;
|
||||
static int g_seq_known, g_took;
|
||||
|
||||
static void *
|
||||
grow(void *p, int *cap, int need, size_t size)
|
||||
{
|
||||
int n = *cap > 0 ? *cap : 64;
|
||||
|
||||
if (need <= *cap) return p;
|
||||
while (n < need) n *= 2;
|
||||
p = SDL_realloc(p, (size_t)n * size);
|
||||
if (p) *cap = n;
|
||||
return p;
|
||||
}
|
||||
|
||||
static int
|
||||
font_add(const char *path)
|
||||
{
|
||||
@@ -252,11 +240,9 @@ atlas_draws(const struct reaktor_font *font, const char *s, int len)
|
||||
static int
|
||||
decode(const char *s, int len)
|
||||
{
|
||||
text_char *p;
|
||||
int n = 0, at = 0;
|
||||
|
||||
if (!(p = grow(g_ch, &g_ch_cap, len, sizeof *g_ch))) return 0;
|
||||
g_ch = p;
|
||||
if (!reaktor_grow((void **)&g_ch, &g_ch_cap, len, sizeof *g_ch)) return 0;
|
||||
while (at < len) {
|
||||
kbts_decode d = kbts_DecodeUtf8(s + at, (kbts_un)(len - at));
|
||||
|
||||
@@ -355,15 +341,13 @@ choose_fonts(int base, int n)
|
||||
static int
|
||||
split(int n)
|
||||
{
|
||||
text_run *p;
|
||||
int i, r = 0;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (r == 0 || g_ch[i].level != g_ch[i - 1].level ||
|
||||
g_ch[i].script != g_ch[i - 1].script ||
|
||||
g_ch[i].font != g_ch[i - 1].font) {
|
||||
if ((p = grow(g_run, &g_run_cap, r + 1, sizeof *g_run)) != NULL) {
|
||||
g_run = p;
|
||||
if (reaktor_grow((void **)&g_run, &g_run_cap, r + 1, sizeof *g_run)) {
|
||||
g_run[r].from = i;
|
||||
g_run[r].font = g_ch[i].font;
|
||||
g_run[r].level = g_ch[i].level;
|
||||
@@ -464,7 +448,6 @@ shape_run(const text_run *r, float pen)
|
||||
kbts_glyph_iterator it;
|
||||
kbts_glyph *g;
|
||||
shaped *out;
|
||||
void *p;
|
||||
int i;
|
||||
|
||||
if (!c) return pen;
|
||||
@@ -480,9 +463,8 @@ shape_run(const text_run *r, float pen)
|
||||
return pen;
|
||||
}
|
||||
while (kbts_GlyphIteratorNext(&it, &g)) {
|
||||
if (!(p = grow(g_glyph, &g_glyph_cap, g_glyphs + 1, sizeof *g_glyph)))
|
||||
if (!reaktor_grow((void **)&g_glyph, &g_glyph_cap, g_glyphs + 1, sizeof *g_glyph))
|
||||
break;
|
||||
g_glyph = p;
|
||||
out = &g_glyph[g_glyphs++];
|
||||
out->x = pen + (float)g->OffsetX * f->unit;
|
||||
out->y = (float)g->OffsetY * f->unit;
|
||||
@@ -498,7 +480,6 @@ shape(int file, const char *s, int len)
|
||||
{
|
||||
shape_entry *e;
|
||||
Uint32 hash = reaktor_fnv_n(REAKTOR_FNV ^ (Uint32)file, s, (size_t)(len > 0 ? len : 0));
|
||||
void *p;
|
||||
float pen = 0.0f;
|
||||
int i, n, runs, first;
|
||||
|
||||
@@ -516,13 +497,10 @@ shape(int file, const char *s, int len)
|
||||
segment(n);
|
||||
choose_fonts(file, n);
|
||||
runs = split(n);
|
||||
if (!(p = grow(g_order, &g_order_cap, runs, sizeof *g_order))) return -1;
|
||||
g_order = p;
|
||||
if (!reaktor_grow((void **)&g_order, &g_order_cap, runs, sizeof *g_order)) return -1;
|
||||
order(runs);
|
||||
if (!(p = grow(g_entry, &g_entry_cap, g_entries + 1, sizeof *g_entry))) return -1;
|
||||
g_entry = p;
|
||||
if (!(p = grow(g_bytes, &g_byte_cap, g_byte_n + len, 1))) return -1;
|
||||
g_bytes = p;
|
||||
if (!reaktor_grow((void **)&g_entry, &g_entry_cap, g_entries + 1, sizeof *g_entry)) return -1;
|
||||
if (!reaktor_grow((void **)&g_bytes, &g_byte_cap, g_byte_n + len, 1)) return -1;
|
||||
|
||||
first = g_glyphs;
|
||||
for (i = 0; i < runs; i++) pen = shape_run(&g_run[g_order[i]], pen);
|
||||
@@ -624,11 +602,9 @@ static int
|
||||
upload(int page, int x, int y, const FT_Bitmap *bm)
|
||||
{
|
||||
SDL_Rect r;
|
||||
void *p;
|
||||
int w = (int)bm->width, h = (int)bm->rows, bw = w + 2, bh = h + 2, i;
|
||||
|
||||
if (!(p = grow(g_bitmap, &g_bitmap_cap, bw * bh, 1))) return 0;
|
||||
g_bitmap = p;
|
||||
if (!reaktor_grow((void **)&g_bitmap, &g_bitmap_cap, bw * bh, 1)) return 0;
|
||||
SDL_memset(g_bitmap, 0, (size_t)(bw * bh));
|
||||
for (i = 0; i < h; i++)
|
||||
SDL_memcpy(g_bitmap + (i + 1) * bw + 1, bm->buffer + i * bm->pitch, (size_t)w);
|
||||
@@ -638,8 +614,7 @@ upload(int page, int x, int y, const FT_Bitmap *bm)
|
||||
r.h = bh;
|
||||
if (!g_page[page].argb)
|
||||
return SDL_UpdateTexture(g_page[page].tex, &r, g_bitmap, bw);
|
||||
if (!(p = grow(g_pixels, &g_pixel_cap, bw * bh, sizeof *g_pixels))) return 0;
|
||||
g_pixels = p;
|
||||
if (!reaktor_grow((void **)&g_pixels, &g_pixel_cap, bw * bh, sizeof *g_pixels)) return 0;
|
||||
for (i = 0; i < bw * bh; i++)
|
||||
g_pixels[i] = (Uint32)g_bitmap[i] << 24 | 0x00FFFFFF;
|
||||
return SDL_UpdateTexture(g_page[page].tex, &r, g_pixels, bw * 4);
|
||||
@@ -843,7 +818,6 @@ reaktor_text_prepare(struct nk_context *ctx, struct SDL_Renderer *renderer)
|
||||
struct nk_command_custom *c = (struct nk_command_custom *)cmd;
|
||||
const struct reaktor_font *font;
|
||||
text_draw d;
|
||||
void *p;
|
||||
short x, y;
|
||||
unsigned short w, h;
|
||||
int face;
|
||||
@@ -854,8 +828,7 @@ reaktor_text_prepare(struct nk_context *ctx, struct SDL_Renderer *renderer)
|
||||
if (face < 0 || atlas_draws(font, t->string, t->length) ||
|
||||
!font_open(g_face[face].file))
|
||||
continue;
|
||||
if (!(p = grow(g_draw, &g_draw_cap, g_draws + 1, sizeof *g_draw))) break;
|
||||
g_draw = p;
|
||||
if (!reaktor_grow((void **)&g_draw, &g_draw_cap, g_draws + 1, sizeof *g_draw)) break;
|
||||
d.face = face;
|
||||
d.len = t->length;
|
||||
d.height = t->height;
|
||||
|
||||
+3
-7
@@ -13,7 +13,7 @@ fit_button(reaktor_box *box, const reaktor_button_spec *s)
|
||||
char src[192];
|
||||
|
||||
box->w = box->h = 0.0f;
|
||||
box->flags &= ~(REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y);
|
||||
box->flags &= ~(REAKTOR_LAY_FILL);
|
||||
decl_box_from_style(box, NULL, s->style, "button", nb->padding.x, nb->padding.y);
|
||||
if (s->icon && !s->label)
|
||||
w = box->h;
|
||||
@@ -491,9 +491,7 @@ reaktor_swatch(const reaktor_swatch_spec *s)
|
||||
if (!decl_place(REAKTOR_A11Y_BUTTON, s->name, hex, 0u, NULL, &box, &id))
|
||||
return 0;
|
||||
|
||||
reaktor_note_mute(g_frame_app, 1);
|
||||
hit = reaktor_css_button_color(g_frame_app, g_frame_ctx, s->name, s->fill);
|
||||
reaktor_note_mute(g_frame_app, 0);
|
||||
hit = reaktor_css_button_color(g_frame_app, g_frame_ctx, s->fill);
|
||||
|
||||
if (reaktor_focus_activated(g_frame_app, id)) hit = 1;
|
||||
if (hit && s->on_press.fn) s->on_press.fn(s->on_press.user);
|
||||
@@ -658,8 +656,6 @@ reaktor_slider(const reaktor_slider_spec *s)
|
||||
if (!decl_place(REAKTOR_A11Y_SLIDER, s->name, text, 0u, NULL, &box, &id))
|
||||
return;
|
||||
|
||||
reaktor_note_range(g_frame_app, id, now, s->lo, s->hi, s->step);
|
||||
|
||||
reaktor_note_mute(g_frame_app, 1);
|
||||
if (s->value)
|
||||
reaktor_slider_bar(g_frame_app, g_frame_ctx, id, s->value, s->lo, s->hi, s->step);
|
||||
@@ -854,7 +850,7 @@ reaktor_combo_open(const reaktor_combo_spec *s)
|
||||
|
||||
if (open) nk_push_scissor(nk_window_get_canvas(g_frame_ctx), clip);
|
||||
if (s->disc) {
|
||||
struct nk_rect im = reaktor_combo_content(g_frame_ctx, h);
|
||||
struct nk_rect im;
|
||||
|
||||
im.w = im.h = h.h - 2.0f * g_frame_ctx->style.combo.content_padding.y;
|
||||
im.x = h.x + g_frame_ctx->style.combo.content_padding.x;
|
||||
|
||||
+14
-18
@@ -427,32 +427,28 @@ reaktor_soak(void)
|
||||
(void)decl_place(REAKTOR_A11Y_NONE, NULL, NULL, 0u, NULL, &box, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
decl_tip_at(const char *tip, struct nk_rect r, int cursor)
|
||||
static void
|
||||
tip_at(App *app, struct nk_context *ctx, struct nk_rect r, const char *text, int cursor)
|
||||
{
|
||||
const struct nk_input *in = &g_frame_ctx->input;
|
||||
|
||||
if (!tip) return;
|
||||
reaktor_hot_follow(g_frame_app, r, cursor);
|
||||
if (nk_input_is_mouse_hovering_rect(in, r) &&
|
||||
nk_input_is_mouse_hovering_rect(in, g_frame_ctx->current->layout->clip)) {
|
||||
SDL_strlcpy(g_frame_app->tip_text, tip, sizeof g_frame_app->tip_text);
|
||||
g_frame_app->tip = g_frame_app->tip_text;
|
||||
if (!text || !ctx || !ctx->current) return;
|
||||
reaktor_hot_follow(app, r, cursor);
|
||||
if (nk_input_is_mouse_hovering_rect(&ctx->input, r) &&
|
||||
nk_input_is_mouse_hovering_rect(&ctx->input, ctx->current->layout->clip)) {
|
||||
SDL_strlcpy(app->tip_text, text, sizeof app->tip_text);
|
||||
app->tip = app->tip_text;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_tip(App *app, struct nk_rect r, const char *text)
|
||||
{
|
||||
struct nk_context *ctx = app ? app->ctx : NULL;
|
||||
tip_at(app, app ? app->ctx : NULL, r, text, 0);
|
||||
}
|
||||
|
||||
if (!text || !ctx || !ctx->current) return;
|
||||
reaktor_hot_follow(app, r, 0);
|
||||
if (nk_input_is_mouse_hovering_rect(&ctx->input, r) &&
|
||||
nk_input_is_mouse_hovering_rect(&ctx->input, ctx->current->layout->clip)) {
|
||||
SDL_strlcpy(app->tip_text, text, sizeof app->tip_text);
|
||||
app->tip = app->tip_text;
|
||||
}
|
||||
void
|
||||
decl_tip_at(const char *tip, struct nk_rect r, int cursor)
|
||||
{
|
||||
tip_at(g_frame_app, g_frame_ctx, r, tip, cursor);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+12
-2
@@ -194,6 +194,14 @@ typedef struct question {
|
||||
float text_h;
|
||||
} question;
|
||||
|
||||
static float
|
||||
ask_button_w(App *app, struct nk_context *ctx, const char *label)
|
||||
{
|
||||
float w = reaktor_button_width(app, ctx, NULL, label);
|
||||
|
||||
return w > 96.0f ? w : 96.0f;
|
||||
}
|
||||
|
||||
static void
|
||||
ask_body(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
{
|
||||
@@ -210,7 +218,8 @@ ask_body(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
nk_spacer(ctx);
|
||||
nk_layout_row_template_begin(ctx, 36.0f);
|
||||
nk_layout_row_template_push_dynamic(ctx);
|
||||
for (i = 0; i < q->q.count; i++) nk_layout_row_template_push_static(ctx, 96.0f);
|
||||
for (i = 0; i < q->q.count; i++)
|
||||
nk_layout_row_template_push_static(ctx, ask_button_w(app, ctx, q->q.buttons[i]));
|
||||
nk_layout_row_template_end(ctx);
|
||||
nk_spacer(ctx);
|
||||
for (i = 0; i < q->q.count; i++)
|
||||
@@ -259,7 +268,8 @@ reaktor_ask(App *app, const reaktor_question *spec)
|
||||
q->q.text = SDL_memcpy(at, spec->text, SDL_strlen(spec->text) + 1);
|
||||
|
||||
f = reaktor_style_font(app, ".popup-title", 16, 1);
|
||||
w = 104.0f * (float)spec->count + 120.0f;
|
||||
w = 120.0f;
|
||||
for (i = 0; i < spec->count; i++) w += ask_button_w(app, app->ctx, spec->buttons[i]) + 8.0f;
|
||||
if (w < 328.0f) w = 328.0f;
|
||||
q->text_h = 22.0f * (float)(1 + (int)(f->width(f->userdata, f->height, q->q.text,
|
||||
(int)SDL_strlen(q->q.text)) / w));
|
||||
|
||||
+32
-39
@@ -52,14 +52,35 @@ focus_reveal(App *app, const reaktor_a11y_node *t, int n, int pick)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
node_index(const reaktor_a11y_node *t, int n, unsigned id)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].id == id) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
focus_to(App *app, const reaktor_a11y_node *t, int n, int i)
|
||||
{
|
||||
app->focus_id = t[i].id;
|
||||
reaktor_a11y_set_focus(&app->a11y, app->focus_id);
|
||||
app->focus_rect = t[i].bounds;
|
||||
app->focus_seen = 1;
|
||||
app->focus_visible = 1;
|
||||
app->dirty = 1;
|
||||
focus_reveal(app, t, n, i);
|
||||
}
|
||||
|
||||
static void
|
||||
focus_move(App *app, int step)
|
||||
{
|
||||
int n, i, cur = -1, pick = -1, lo, hi;
|
||||
int n, i, cur, pick = -1, lo, hi;
|
||||
const reaktor_a11y_node *t = reaktor_a11y_tree(&app->a11y, &n);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].id == app->focus_id) { cur = i; break; }
|
||||
cur = node_index(t, n, app->focus_id);
|
||||
lo = 0;
|
||||
hi = n - 1;
|
||||
if (app->popup_hi >= 0 && app->popup_hi < n) {
|
||||
@@ -88,14 +109,7 @@ focus_move(App *app, int step)
|
||||
}
|
||||
}
|
||||
if (pick < 0) return;
|
||||
|
||||
app->focus_id = t[pick].id;
|
||||
reaktor_a11y_set_focus(&app->a11y, app->focus_id);
|
||||
app->focus_rect = t[pick].bounds;
|
||||
app->focus_seen = 1;
|
||||
app->focus_visible = 1;
|
||||
app->dirty = 1;
|
||||
focus_reveal(app, t, n, pick);
|
||||
focus_to(app, t, n, pick);
|
||||
if (t[pick].role == REAKTOR_A11Y_TEXTBOX) reaktor_key_click_ask(app);
|
||||
}
|
||||
|
||||
@@ -113,11 +127,7 @@ focus_resolve(App *app)
|
||||
const reaktor_a11y_node *t = reaktor_a11y_tree(&app->a11y, &n);
|
||||
|
||||
if (!app->focus_id) return;
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].id == app->focus_id) {
|
||||
if (focusable(&t[i])) return;
|
||||
break;
|
||||
}
|
||||
if ((i = node_index(t, n, app->focus_id)) >= 0 && focusable(&t[i])) return;
|
||||
app->focus_id = 0;
|
||||
reaktor_a11y_set_focus(&app->a11y, 0);
|
||||
}
|
||||
@@ -129,13 +139,9 @@ focus_steps(App *app)
|
||||
int n, i;
|
||||
const reaktor_a11y_node *t = reaktor_a11y_tree(&app->a11y, &n);
|
||||
|
||||
if (!app->focus_id) return 0;
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].id == app->focus_id)
|
||||
return t[i].role == REAKTOR_A11Y_SLIDER ||
|
||||
t[i].role == REAKTOR_A11Y_SPINBUTTON ? 1
|
||||
: t[i].role == REAKTOR_A11Y_TREEITEM ? 2 : 0;
|
||||
return 0;
|
||||
if (!app->focus_id || (i = node_index(t, n, app->focus_id)) < 0) return 0;
|
||||
return t[i].role == REAKTOR_A11Y_SLIDER || t[i].role == REAKTOR_A11Y_SPINBUTTON ? 1
|
||||
: t[i].role == REAKTOR_A11Y_TREEITEM ? 2 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -231,17 +237,7 @@ reader_focus(void *user, unsigned id)
|
||||
int n, i;
|
||||
const reaktor_a11y_node *t = reaktor_a11y_tree(&app->a11y, &n);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].id == id) {
|
||||
app->focus_id = id;
|
||||
reaktor_a11y_set_focus(&app->a11y, id);
|
||||
app->focus_rect = t[i].bounds;
|
||||
app->focus_seen = 1;
|
||||
app->focus_visible = 1;
|
||||
app->dirty = 1;
|
||||
focus_reveal(app, t, n, i);
|
||||
return;
|
||||
}
|
||||
if ((i = node_index(t, n, id)) >= 0) focus_to(app, t, n, i);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -335,11 +331,8 @@ focus_ring(App *app, struct nk_context *ctx, struct nk_command_buffer *cv)
|
||||
int n, i, in_page = 0;
|
||||
const reaktor_a11y_node *t = reaktor_a11y_tree(&app->a11y, &n);
|
||||
|
||||
for (i = 0; i < n && app->focus_layer == FOCUS_PAGE; i++)
|
||||
if (t[i].id == app->focus_id) {
|
||||
in_page = node_under(t, n, i, app->page_node);
|
||||
break;
|
||||
}
|
||||
if (app->focus_layer == FOCUS_PAGE && (i = node_index(t, n, app->focus_id)) >= 0)
|
||||
in_page = node_under(t, n, i, app->page_node);
|
||||
if (in_page) nk_push_scissor(cv, app->body_rect);
|
||||
/* Truncated as nk_widget truncates the chrome it surrounds. */
|
||||
r = reaktor_rect_trunc(r);
|
||||
|
||||
+13
-17
@@ -489,19 +489,28 @@ int
|
||||
css_button_icon(App *app, struct nk_context *ctx, const char *selector,
|
||||
const char *icon_src, const char *label)
|
||||
{
|
||||
reaktor_button_look k;
|
||||
reaktor_style_frame f;
|
||||
int clicked;
|
||||
|
||||
hot_push(app, nk_widget_bounds(ctx), REAKTOR_CURSOR_POINTER, 1);
|
||||
reaktor_note_here(app, ctx, REAKTOR_A11Y_BUTTON, label, 0);
|
||||
reaktor_button_look_of(selector, &k);
|
||||
f = push_button_look(app, ctx, &k);
|
||||
f = push_button_style(app, ctx, selector);
|
||||
clicked = group_press(app, ctx, selector, icon_src, label);
|
||||
reaktor_style_frame_pop(ctx, f);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
static int
|
||||
press_blank(struct nk_context *ctx)
|
||||
{
|
||||
int clicked;
|
||||
|
||||
reaktor_button_arm(ctx);
|
||||
clicked = nk_button_text(ctx, "", 0);
|
||||
reaktor_chrome_disarm();
|
||||
return clicked;
|
||||
}
|
||||
|
||||
/* The sheet's button with nothing in it; the caller paints the inside. */
|
||||
int
|
||||
reaktor_css_button_custom(App *app, struct nk_context *ctx, const char *sel,
|
||||
@@ -519,9 +528,7 @@ reaktor_css_button_custom(App *app, struct nk_context *ctx, const char *sel,
|
||||
reaktor_button_look_of(sel, &k);
|
||||
in_x = button_inset(ctx, &k.s, 0);
|
||||
f = push_button_look(app, ctx, &k);
|
||||
reaktor_button_arm(ctx);
|
||||
clicked = nk_button_text(ctx, "", 0);
|
||||
reaktor_chrome_disarm();
|
||||
clicked = press_blank(ctx);
|
||||
if (paint) {
|
||||
float in_y = k.s.matched ? k.s.pad_y : ctx->style.button.padding.y;
|
||||
struct nk_rect c = nk_rect(b.x + in_x, b.y + in_y, b.w - 2.0f * in_x, b.h - 2.0f * in_y);
|
||||
@@ -534,17 +541,6 @@ reaktor_css_button_custom(App *app, struct nk_context *ctx, const char *sel,
|
||||
return clicked;
|
||||
}
|
||||
|
||||
static int
|
||||
press_blank(struct nk_context *ctx)
|
||||
{
|
||||
int clicked;
|
||||
|
||||
reaktor_button_arm(ctx);
|
||||
clicked = nk_button_text(ctx, "", 0);
|
||||
reaktor_chrome_disarm();
|
||||
return clicked;
|
||||
}
|
||||
|
||||
static void
|
||||
image_centered(struct nk_context *ctx, struct nk_rect b, struct nk_image im, float px)
|
||||
{
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ reaktor_toasts_draw(App *app, struct nk_context *ctx, int win_w, int win_h,
|
||||
}
|
||||
}
|
||||
if (t->action &&
|
||||
reaktor_button_label_as(app, ctx, ".toast-button", t->action))
|
||||
css_button(app, ctx, ".toast-button", t->action))
|
||||
act = first + i;
|
||||
if (!t->spec.no_close &&
|
||||
reaktor_css_button_image(
|
||||
|
||||
+1
-1
@@ -411,7 +411,7 @@ list_draw(const reaktor_list_spec *s, tree_rows *t)
|
||||
}
|
||||
}
|
||||
|
||||
body.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y;
|
||||
body.flags = REAKTOR_LAY_FILL;
|
||||
if (decl_place(REAKTOR_A11Y_NONE, NULL, NULL, 0u, NULL, &body, NULL)) {
|
||||
struct nk_rect area = nk_widget_bounds(g_frame_ctx);
|
||||
int focused = -1;
|
||||
|
||||
+3
-22
@@ -496,13 +496,6 @@ reaktor_button_label(App *app, struct nk_context *ctx, const char *label)
|
||||
return css_button(app, ctx, "button", label);
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_button_label_as(App *app, struct nk_context *ctx, const char *sel,
|
||||
const char *label)
|
||||
{
|
||||
return css_button(app, ctx, sel, label);
|
||||
}
|
||||
|
||||
/* A button's icon is drawn white and tinted with its label's color. */
|
||||
const char *
|
||||
reaktor_button_src(char out[192], const char *ionicon)
|
||||
@@ -579,17 +572,12 @@ reaktor_unfit_label(struct nk_context *ctx, int fitted)
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_css_button_color(App *app, struct nk_context *ctx, const char *name,
|
||||
struct nk_color fill)
|
||||
reaktor_css_button_color(App *app, struct nk_context *ctx, struct nk_color fill)
|
||||
{
|
||||
struct nk_rect b = nk_widget_bounds(ctx);
|
||||
unsigned char hov[4];
|
||||
char hex[10];
|
||||
int clicked;
|
||||
|
||||
hot_push(app, b, REAKTOR_CURSOR_POINTER, 1);
|
||||
reaktor_hex(fill, hex);
|
||||
reaktor_note(app, REAKTOR_A11Y_BUTTON, name, hex, 0, b);
|
||||
hot_push(app, nk_widget_bounds(ctx), REAKTOR_CURSOR_POINTER, 1);
|
||||
|
||||
hov[0] = fill.r; hov[1] = fill.g; hov[2] = fill.b; hov[3] = fill.a;
|
||||
reaktor_style_darken(hov, 0.12f);
|
||||
@@ -1014,14 +1002,7 @@ unsigned
|
||||
reaktor_note_here(App *app, struct nk_context *ctx, unsigned char role,
|
||||
const char *name, unsigned state)
|
||||
{
|
||||
struct nk_rect b;
|
||||
unsigned id;
|
||||
|
||||
if (g_note_mute) return 0;
|
||||
b = nk_widget_bounds(ctx);
|
||||
id = reaktor_a11y_add(&app->a11y, role, name, NULL, state, b);
|
||||
focus_saw(app, id, b);
|
||||
return id;
|
||||
return reaktor_note(app, role, name, NULL, state, nk_widget_bounds(ctx));
|
||||
}
|
||||
|
||||
const struct nk_user_font *
|
||||
|
||||
+77
-31
@@ -94,7 +94,7 @@ followed by a frame.
|
||||
| Call | Effect |
|
||||
| --- | --- |
|
||||
| `reaktor_file_dialog_open(app, &(reaktor_file_dialog){ ... })` | The system picker. `.kind`: `REAKTOR_FILE_OPEN`, `_SAVE` or `REAKTOR_FOLDER_OPEN`. `.filters` (`"png;jpg"` patterns, kept alive until the answer), `.location`, `.many`. `.chosen(app, paths, count, user)` gets `count` 0 on cancel. One per window; answers 0 while one is open |
|
||||
| `reaktor_ask(app, &(reaktor_question){ ... })` | A modal floater: `.text` and one button per `.buttons` entry, the last accented. `.answered(app, button, user)` runs once; -1 if closed another way. The spec is copied |
|
||||
| `reaktor_ask(app, &(reaktor_question){ ... })` | A modal floater: `.text` and one button per `.buttons` entry, each at least as wide as its label, the last accented. `.answered(app, button, user)` runs once; -1 if closed another way. The spec is copied |
|
||||
| `reaktor_timer(app, ms, repeat, fn, user)` | `fn(app, user)` after `ms`, every `ms` with `repeat`; answers an id. Stops when the window closes |
|
||||
| `reaktor_timer_stop(id)` | Stop one |
|
||||
| `reaktor_post(app, fn, user)` | `fn(app, user)` on the main thread. Any thread; immediate on the main one |
|
||||
@@ -453,7 +453,7 @@ A container's fields, and a widget's `.box`:
|
||||
| `.weight` | Its share of the space left over, against its siblings; 0 reads as 1 |
|
||||
| `.gap` | Between its children |
|
||||
| `.ml .mt .mr .mb` | Margins |
|
||||
| `.flags` | `REAKTOR_LAY_FILL_X`, `_FILL_Y`, `_WRAP`, `_CENTER_X`, `_CENTER_Y`, `_PACK_CENTER`, `_PACK_END`, `_PACK_SPREAD` |
|
||||
| `.flags` | `REAKTOR_LAY_FILL_X`, `_FILL_Y`, `_FILL` (both), `_WRAP`, `_CENTER_X`, `_CENTER_Y`, `_PACK_CENTER`, `_PACK_END`, `_PACK_SPREAD` |
|
||||
| `.name` | How a container is found again; a widget uses its spec's `.name` |
|
||||
| `.mark` | A handle for a [scripted test](#testing-an-application), on a widget or a container: `"#mark"` finds it, `"#mark Delete"` finds Delete inside it, and no reader hears it. One mark may sit on many widgets, every row of a list for one; up to 63 characters are kept. Marks are kept apart from the tree, in a table made only once something sets one; `--a11y-dump` lists them after the tree |
|
||||
|
||||
@@ -635,9 +635,8 @@ Water.css's palette (`variables-light.css` or `variables-dark.css`), Water.css
|
||||
(`parts/_core.css` and the parts it imports), `reaktor.css`, the application's
|
||||
`.css`, then `--css`. Nothing merges them. An `@import` is read in place,
|
||||
relative to the sheet that names it; one with a condition, such as
|
||||
`(prefers-color-scheme: dark)`, is read as that `@media` block. A selector or
|
||||
value longer than libcss holds as one token, or a value with a `;` in it, is
|
||||
dropped before libcss sees it. A field filled exactly like the rounded panel it sits on
|
||||
`(prefers-color-scheme: dark)`, is read as that `@media` block. A field filled
|
||||
exactly like the rounded panel it sits on
|
||||
takes the page's color instead, so a sheet that styles `input` and `details`
|
||||
alike still shows its fields on a card.
|
||||
|
||||
@@ -689,22 +688,10 @@ and the accent. An icon on a button takes its label's color.
|
||||
row of buttons starts and ends where the field below it does, and each line
|
||||
of a row that wraps starts at the edge. A margin set in code always counts,
|
||||
and a `REAKTOR_FREE` box keeps all four.
|
||||
- **libcss is not a browser.** `cssflat.c` resolves `var()`, works out
|
||||
`color-mix(in srgb, …)`, writes every `rgb()` as `rgba()` with four
|
||||
arguments, clamped, turns `em` and `rem` into pixels, works out `calc()`
|
||||
over pixels and plain numbers (one with a percentage is left, and dropped),
|
||||
keeps an `@media` block whose queries are all `prefers-color-scheme`,
|
||||
`prefers-reduced-motion` or `prefers-contrast` and hold now, and drops
|
||||
width and print queries, rewrites `[type=range]` as `.type-range`
|
||||
and `[disabled]` as `.disabled`, and drops `:enabled`, since every widget
|
||||
that asks is enabled and a disabled one asks for `:disabled`. An operator
|
||||
form like `[href^="http"]` cannot be expressed, and its rule is dropped, as
|
||||
is a declaration with a color it cannot read, and a selector that names a
|
||||
class or pseudo-class twice in one compound: given two `:not()`, libcss
|
||||
frees a list and goes on using it. Sheets are read in the C locale's numbers
|
||||
whatever the program's locale.
|
||||
reaktor.css uses the scheme branch to strengthen light hovers and tint the
|
||||
current sidebar entry from `--links`.
|
||||
- **The engine is Reaktor's own, and small.** `core/css/css.c` reads the
|
||||
sheets once into typed values; [What the engine reads](#what-the-engine-reads)
|
||||
lists all of it. reaktor.css uses the scheme branch to strengthen light
|
||||
hovers and tint the current sidebar entry from `--links`.
|
||||
|
||||
**The system's settings.** Reduced motion and high contrast are read from the
|
||||
system: Windows' animation and high-contrast settings, macOS's accessibility
|
||||
@@ -729,6 +716,65 @@ names, so once such a sheet is read, `--links`, `--background-body` and
|
||||
last; Reaktor's own chrome then follows it too. A sheet laid over Water.css
|
||||
costs a second read.
|
||||
|
||||
|
||||
### What the engine reads
|
||||
|
||||
A widget's selector names one element and its ancestors, such as
|
||||
`button.disabled:disabled:hover` or `button .icon`. A rule applies when each of
|
||||
its compounds names a subset of what the query names, in order.
|
||||
|
||||
| At-rule | Read as |
|
||||
| --- | --- |
|
||||
| `@import url(…)` or `@import "…"` | Before any rule, as CSS allows it: the sheet, in place, relative to the one that names it; with a condition, as that `@media` block. Eight deep and 256 sheets at most, and a sheet past 4 MB is skipped |
|
||||
| `@media` | Kept when one of its comma-separated queries names only `prefers-color-scheme`, `prefers-reduced-motion` or `prefers-contrast`, each true now, with `only`, `and`, `screen` or `all` beside them. Width, print and every other query drop the block |
|
||||
| Any other | Skipped with its block: `@font-face`, `@keyframes`, `@supports`, `@layer` |
|
||||
|
||||
| Selector | Read as |
|
||||
| --- | --- |
|
||||
| `button`, `*`, `.class`, `#id` | As CSS writes them, escapes such as `\:` and `\31 ` decoded |
|
||||
| `[attr]`, `[attr=value]` | The class `attr` or `attr-value`, so `[type=range]` answers `input.type-range` and `[disabled]` answers `.disabled` |
|
||||
| `:hover`, `:active`, `:focus`, `:disabled`, `:link`, any other pseudo-class | Holds when the query names it |
|
||||
| `:enabled` | Holds unless the query names `:disabled` |
|
||||
| `:not(…)` | Holds when none of its simple selectors does; it counts as its most specific argument |
|
||||
| `a b`, `a > b` | Descendant and child |
|
||||
| `a + b`, `a ~ b`, `::before`, `[href^="…"]` and the other operators | Drop that selector; the rest of its list stays |
|
||||
|
||||
The cascade is CSS's: `!important` first, then specificity (ids, then classes,
|
||||
attributes and pseudo-classes, then types), then the later rule. Nothing is
|
||||
inherited: a widget reads its own selector, and the page reads `body`. `inherit`,
|
||||
`initial`, `unset` and `revert` all give a property its initial value.
|
||||
|
||||
Custom properties come from rules that match the root in the active theme
|
||||
(`:root`, `html`, `[data-theme="dark"]`, `:root:not([data-theme="dark"])`) and
|
||||
from `::backdrop`, into one set where the last declaration wins.
|
||||
`var(--name, fallback)` nests, to 32 levels, 1,024 substitutions and 4 KB of
|
||||
expanded text; one that cannot resolve unsets its property. `rem` is the root's
|
||||
font size, `em` the body's, each from the rule that wins for it. A sheet left
|
||||
open at its end, in a comment, string or block, is closed there.
|
||||
|
||||
| Value | Read as |
|
||||
| --- | --- |
|
||||
| Colors | Names, `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()`, `rgba()`, `hsl()`, `hsla()` with commas or spaces and `/` before the alpha, `transparent`, `currentcolor`, and `color-mix(in srgb, a [p%], b [q%])` |
|
||||
| Lengths | `px`, `em` (the body's font size), `rem` (the root's), `0`, and `calc()` with `+ - * /` over those and plain numbers. `auto` and `none` are 0. A percentage, `vw`, `vh`, `pt` or `ch` drops the declaration |
|
||||
|
||||
| Property | Notes |
|
||||
| --- | --- |
|
||||
| `color`, `background-color` | |
|
||||
| `background` | Its color, wherever it stands among the layers; one with none is transparent |
|
||||
| `border`, `border-top`, `-right`, `-bottom`, `-left` | Width, style and color in any order. A side with no style has no width; one with no color takes the text's |
|
||||
| `border-width`, `border-style`, and each side's | One to four values; `thin`, `medium` and `thick` are 1, 3 and 5 px |
|
||||
| `border-color`, `border-top-color` | The top color is the one a widget draws |
|
||||
| `border-radius` and each corner's | One to four values; an elliptical corner takes its first radius |
|
||||
| `padding`, `margin`, and each side's | One to four values; `auto` is 0 |
|
||||
| `width`, `height`, `min-width`, `min-height`, `max-width`, `max-height` | |
|
||||
| `font-size` | A length, or a percentage of the body's |
|
||||
| `font-weight` | `normal`, `bold`, `bolder`, `lighter` or 100 to 900; 600 and up is bold |
|
||||
| `line-height` | `normal`, a number or a percentage of the font size, or a length |
|
||||
| `opacity` | A number or a percentage |
|
||||
|
||||
Every other property is read and left alone. A rule with none of these
|
||||
properties does not count toward `matched`.
|
||||
|
||||
## Keyboard
|
||||
|
||||
| Keys | Do |
|
||||
@@ -854,7 +900,7 @@ flowchart TB
|
||||
ren["<b>core/render</b><br/>Nuklear, then the SDL3 software rasterizer"]
|
||||
sdl["<b>SDL3</b><br/>window, input, surface, dialogs, tray"]
|
||||
|
||||
css["<b>core/css</b><br/>cssflat, libcss, style_map"]
|
||||
css["<b>core/css</b><br/>the CSS engine, style_map"]
|
||||
tree["<b>core/a11y + core/anim</b><br/>the shadow tree, eased values"]
|
||||
plat["<b>platform/</b><br/>UIA, NSAccessibility, AT-SPI, DOM"]
|
||||
|
||||
@@ -868,7 +914,7 @@ flowchart TB
|
||||
include/reaktor the public API; launch.h and main.h come first
|
||||
core/internal.h the App struct, and what the layers share
|
||||
core/base paths, metrics, assets
|
||||
core/css cssflat and the libcss front end
|
||||
core/css the CSS engine and the style cache
|
||||
core/render Nuklear, the SDL3 backend, drawing, SVG and raster images
|
||||
core/ui the declared tree (declare.c), its controls and views, layout,
|
||||
the style map, keys, focus, floaters, toasts
|
||||
@@ -903,8 +949,7 @@ catalogs are read from files; an icon that is not there is drawn as nothing,
|
||||
and the log names it.
|
||||
|
||||
**`style_map.c` is the only writer of `nk_style`.** A widget style set
|
||||
anywhere else lasts until a theme change reloads the sheets. libcss never
|
||||
takes a sheet's rules back out of its store, so every load rebuilds it.
|
||||
anywhere else lasts until a theme change reloads the sheets.
|
||||
|
||||
## The frame loop
|
||||
|
||||
@@ -960,9 +1005,10 @@ repaint to make something update is the wrong fix** — mark what changed.
|
||||
| NetBSD | x86-64, ARM64 | 11.0 |
|
||||
| Web | WebAssembly | Chromium; emscripten 6.0.9 targets Chrome 85, Firefox 79 and Safari 15 |
|
||||
|
||||
Every pull request builds each native one, runs the eight console tests, and
|
||||
writes a `--shot` and an `--a11y-dump` of `simple` and the showcase through
|
||||
the system's video driver and SDL's `dummy` one: `.github/workflows/` holds a
|
||||
Every pull request builds each native one, runs the ten console tests that
|
||||
`tools/ci/tests.txt` lists, and writes a `--shot` and an `--a11y-dump` of
|
||||
`simple` and the showcase through the system's video driver and SDL's `dummy`
|
||||
one: `.github/workflows/` holds a
|
||||
workflow per system. The BSDs run in virtual machines, and their ARM64
|
||||
programs are cross-compiled in the x86-64 machine, against a sysroot
|
||||
`tools/cross/sysroot.sh` gathers from the release's sets and packages, with
|
||||
@@ -1023,7 +1069,7 @@ cmake --install build --prefix libreaktor --component libreaktor
|
||||
```
|
||||
|
||||
It is one static library — `reaktor.lib` with MSVC, `libreaktor.a` elsewhere
|
||||
— holding Reaktor, every module, SDL, libcss, plutosvg, Onlay, NukAnim,
|
||||
— holding Reaktor, every module, SDL, FreeType, plutosvg, Onlay, NukAnim,
|
||||
mojibake and kb_text_shape, merged with `lib.exe`, Apple's `libtool` or an
|
||||
`ar` MRI script. Beside it go the public headers with Nuklear's, NukAnim's
|
||||
and SDL's, a CMake package, a pkg-config file and `share/reaktor/licenses`:
|
||||
@@ -1052,7 +1098,7 @@ the current build, into `build/dist`; each release carries both, built by CI.
|
||||
|
||||
```bash
|
||||
sh tools/libreaktor-pkg.sh -i
|
||||
./build.sh --target deb
|
||||
./build.sh deb
|
||||
```
|
||||
|
||||
The prefix is `/opt/reaktor` on Linux and `/usr/local/reaktor` on the BSDs,
|
||||
@@ -1197,7 +1243,7 @@ Built by default and run from `build/`:
|
||||
| `animtest` | Curves, retargeting, a context a window |
|
||||
| `keytest` | Chord parsing and formatting |
|
||||
| `localetest` | Catalogs, lookup, plural rules, formatting |
|
||||
| `csstest` | Flattening a sheet for libcss: what is rewritten, what is dropped, and Simple.css read through it |
|
||||
| `csstest` | The CSS engine: matching, the cascade, values, `@media`, hostile sheets, and Simple.css read through it |
|
||||
| `imagetest` | PNG and JPEG decode; other formats are not compiled in |
|
||||
| `basetest` | Which URL schemes a link opens, and UTF-8 cleaning |
|
||||
| `uitest` | The scripted UI test below, driving its own window: find by name and mark, click, type, a check box, a key hook |
|
||||
|
||||
+5
-5
@@ -108,11 +108,11 @@ axis. Leave the axis unset and the rule applies. See
|
||||
|
||||
### Why can't I use `em` or `rem`, and how far do `var()` and `color-mix()` go?
|
||||
|
||||
You can: the engine underneath, libcss, has neither, so `cssflat.c` turns
|
||||
them into pixels before it reads the sheet. It also resolves `var()`, works
|
||||
out `color-mix(in srgb, …)` and `calc()` over pixels, and keeps the
|
||||
`prefers-color-scheme` branch for the active scheme. Operator selectors such
|
||||
as `[href^="http"]` are dropped. See [Styling](DOCUMENTATION.md#styling).
|
||||
You can: `em` is the body's font size and `rem` the root's. The engine also
|
||||
resolves `var()`, works out `color-mix(in srgb, …)` and `calc()` over pixels,
|
||||
and keeps the `prefers-color-scheme` branch for the active scheme. Percentages
|
||||
are not lengths, and operator selectors such as `[href^="http"]` are dropped.
|
||||
See [Styling](DOCUMENTATION.md#styling).
|
||||
|
||||
### How do I ship my own stylesheet or theme?
|
||||
|
||||
|
||||
+7
-6
@@ -10,7 +10,6 @@ from the project's own license file at the pinned revision.
|
||||
| [SDL](https://github.com/libsdl-org/SDL) | Window, input, renderer, system theme, file dialog, tray | zlib |
|
||||
| [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) | Widgets and the SDL3 backend | MIT **or** public domain |
|
||||
| [NukAnim](https://github.com/Alpaq92/NukAnim) | Every animation, and `nukanim.h` for applications — a port of [ImAnim](https://github.com/soufianekhiat/ImAnim) with [ImAnimate](https://github.com/RaidcoreGG/ImAnimate)'s `animate` | MIT |
|
||||
| [LCUI](https://github.com/lc-soft/LCUI) | `libcss` (parse, match, cascade) and `yutil` | MIT |
|
||||
| [Onlay](https://github.com/Alpaq92/Onlay) | The rectangles — a fork of [randrew/layout](https://github.com/randrew/layout) | MIT |
|
||||
| [Water.css](https://github.com/kognise/water.css) | The stylesheet the look comes from, compiled in | MIT |
|
||||
| [Simple.css](https://github.com/kevquirk/simple.css) | Alternative style used in the demo app | MIT |
|
||||
@@ -22,10 +21,9 @@ from the project's own license file at the pinned revision.
|
||||
| [kb_text_shape](https://github.com/JimmyLefevre/kb) | OpenType shaping, script segmentation and font coverage, for the Text module | zlib |
|
||||
| [ini.h](https://github.com/mattiasgustavsson/libs) | Reading and writing `settings.conf` | MIT **or** public domain |
|
||||
|
||||
Only LCUI's `libcss` and `yutil` are built, not the toolkit. SDL is built
|
||||
static, without audio, joystick, haptic, HID, sensor, camera, power, GPU,
|
||||
offscreen, the render backends Reaktor never selects, or its dynamic API (see
|
||||
below). Its tray is built: on
|
||||
SDL is built static, without audio, joystick, haptic, HID, sensor, camera,
|
||||
power, GPU, offscreen, the render backends Reaktor never selects, or its
|
||||
dynamic API (see below). Its tray is built: on
|
||||
Linux and the BSDs it loads AppIndicator and GTK 3 when a tray opens, and
|
||||
nothing links them. mojibake is built without its collation, IDNA, security
|
||||
and character-name tables. NukAnim is one header, compiled in
|
||||
@@ -36,6 +34,9 @@ its TrueType, CFF, auto-hinter and anti-aliasing modules, and
|
||||
`core/render/ft/reaktor_ftoption.h` turns off what Reaktor never reads, its
|
||||
environment override among them.
|
||||
|
||||
The stylesheets are read by Reaktor's own engine, `core/css/css.c`; no CSS
|
||||
library is linked or copied.
|
||||
|
||||
Portions of this software are copyright © 2026 The FreeType Project
|
||||
(https://freetype.org). All rights reserved.
|
||||
|
||||
@@ -138,7 +139,7 @@ each toolchain fetches its own framework, and none is part of a Reaktor build.
|
||||
|
||||
## What is redistributed
|
||||
|
||||
A native build links SDL, libcss, yutil, plutosvg, plutovg and FreeType
|
||||
A native build links SDL, plutosvg, plutovg and FreeType
|
||||
statically, plus mojibake and kb_text_shape with the Text module, and compiles
|
||||
in Nuklear, NukAnim, Onlay and ini.h, so it carries the zlib, MIT and FreeType
|
||||
License terms above. Each license
|
||||
|
||||
+39
-34
@@ -11,8 +11,8 @@ queue and builds a frame only when the picture would differ. So **CPU is a
|
||||
count of frames, not a load**, and **memory is a floor, not a curve**: once the
|
||||
atlas and icons are baked, nothing grows.
|
||||
|
||||
On Windows today, `showcase.exe` is 3,392,512 bytes, `notepad.exe` 2,351,616,
|
||||
`simple.exe` 2,238,464 and `bench.exe` 2,228,224. The showcase links all three
|
||||
On Windows today, `showcase.exe` is 3,327,488 bytes, `notepad.exe` 2,294,784,
|
||||
`simple.exe` 2,181,632 and `bench.exe` 2,171,904. The showcase links all three
|
||||
optional modules and the others none; each carries the default look —
|
||||
Aileron, the mark, the sheets and seven icons, 73,123 bytes — compiled in. The
|
||||
four-platform figures below come from an older build that shipped one
|
||||
@@ -22,11 +22,11 @@ the one all four programs share.
|
||||
## Against the others
|
||||
|
||||

|
||||
Memory: Reaktor 8.5 MB, the same binary on D3D11 57.6 MB, on D3D12 121.4 MB
|
||||
and on OpenGL 69.7 MB, Flutter 132.7 MB, Electron 156.3 MB, Kotlin
|
||||
Multiplatform 668.7 MB. Steady-state CPU as a percent of one core: Reaktor
|
||||
6.7%, D3D11 13.4%, D3D12 5.6%, OpenGL 5.6%, Flutter 15.3%, Electron 19.6%,
|
||||
Kotlin Multiplatform 29.4%](benchmark.svg)
|
||||
|
||||
The workload is [ShaftUI/Shaft](https://github.com/ShaftUI/Shaft)'s: 64 boxes
|
||||
rotating at 60 fps in an 800×600 window, every arm on the same machine: a
|
||||
@@ -39,22 +39,23 @@ plotted: it does not link on Windows.
|
||||
|
||||
| Arm | Memory | CPU, with startup | CPU, steady state |
|
||||
| --- | --- | --- | --- |
|
||||
| **Reaktor**, `software` | 8.9 MB | 8.2% | 7.0% |
|
||||
| **Reaktor**, `direct3d11` | 58.2 MB | 14.2% | 13.0% |
|
||||
| **Reaktor**, `direct3d12` | 121.3 MB | 11.7% | 6.0% |
|
||||
| **Reaktor**, `opengl` | 69.3 MB | 11.8% | 6.4% |
|
||||
| Flutter | 90.8 MB | 19.3% | 15.6% |
|
||||
| Electron | 157.6 MB | 40.8% | 26.1% |
|
||||
| Kotlin Multiplatform | 667.4 MB | 59.6% | 33.5% |
|
||||
| **Reaktor**, `software` | 8.5 MB | 8.0% | 6.7% |
|
||||
| **Reaktor**, `direct3d11` | 57.6 MB | 14.4% | 13.4% |
|
||||
| **Reaktor**, `direct3d12` | 121.4 MB | 10.8% | 5.6% |
|
||||
| **Reaktor**, `opengl` | 69.7 MB | 11.0% | 5.6% |
|
||||
| Flutter | 132.7 MB | 38.8% | 15.3% |
|
||||
| Electron | 156.3 MB | 36.5% | 19.6% |
|
||||
| Kotlin Multiplatform | 668.7 MB | 51.5% | 29.4% |
|
||||
|
||||
- **About a tenth of Flutter's memory and less than half its CPU**, with
|
||||
startup or without, and a seventieth of Kotlin Multiplatform's memory.
|
||||
- **About a fifteenth of Flutter's memory and less than half its CPU**, with
|
||||
startup or without, and nearly an eightieth of Kotlin Multiplatform's
|
||||
memory.
|
||||
- **Every Reaktor renderer takes less CPU than every other framework.** On a
|
||||
GPU renderer its memory is mostly the graphics driver's: 58–121 MB, around
|
||||
Flutter's 91.
|
||||
GPU renderer its memory is mostly the graphics driver's: 58–121 MB, below
|
||||
Flutter's 133.
|
||||
- **Startup counts.** A run that draws for only 0.2 s takes 0.14 s of CPU on
|
||||
`software` and 0.38–0.50 s on a GPU renderer. Once running, `direct3d12` and
|
||||
`opengl` take up to a point less than `software`.
|
||||
`opengl` take about a point less than `software`.
|
||||
- **A GPU renderer's CPU depends on what else uses the GPU.** With another
|
||||
program keeping it busy, `direct3d11` and `opengl` missed 60 fps and took
|
||||
16–28% of a core. These runs had the GeForce RTX 2060 idle.
|
||||
@@ -77,8 +78,10 @@ median of ten runs, the steady-state ones taken in turn across arms; passes
|
||||
differ by up to three points of CPU. Memory is peak private bytes, and CPU the
|
||||
sum, across each app's process tree. `-PinClock` runs on a copy of the power
|
||||
plan that holds the processor at full speed, and restores the plan after.
|
||||
The Reaktor rows were measured on 2026-10-23, the others on 2026-10-22, with
|
||||
the GPU idle. The sampler counts what an app's own timers miss: `bench` times
|
||||
Every row was measured on 2026-10-24 in one pass, with the GPU idle: Flutter
|
||||
3.47.8, Electron 44.3.0, and Kotlin 2.4.20 with Compose 1.12.0 on JDK 21. The
|
||||
Flutter arm took 91 MB and 19% of a core with startup on the Flutter release
|
||||
used before; 3.47.8 takes more of both. The sampler counts what an app's own timers miss: `bench` times
|
||||
0.07 ms of work per `direct3d11` frame, where the sampler charged over 10%.
|
||||
`vulkan` falls back to `direct3d11` in this SDL build.
|
||||
|
||||
@@ -101,20 +104,22 @@ kb_text_shape with Text — so only the C runtime loads from outside. The web
|
||||
bundles agree within 211 bytes on Windows, Linux and macOS (emscripten 6.0.9),
|
||||
and 380 with GhostBSD's emscripten 6.0.3; the Linux one is 1,221,689 bytes of
|
||||
`.wasm`, 86,001 of assets, 80,045 of `.js` and 1,451 of `.html`. Today's
|
||||
build also links FreeType, which bakes the glyph atlas. The Windows
|
||||
build also links FreeType, which bakes the glyph atlas, and reads the
|
||||
stylesheets with its own engine in place of libcss. The Windows
|
||||
binary's icon is a 125 KB resource of nine sizes, built from the SVG by
|
||||
`tools/mkicon.c`.
|
||||
|
||||
### Modules
|
||||
|
||||
`showcase`, each module off in turn; native on the Windows machine below, web
|
||||
on Windows emsdk 6.0.9.
|
||||
on Windows emsdk 6.0.9. The web rows are from the build before the CSS engine
|
||||
replaced libcss.
|
||||
|
||||
| `showcase` | Default | Module off | Saved |
|
||||
| --- | --- | --- | --- |
|
||||
| `.exe`, accessibility bridges | 3,392,512 | 3,375,616 | 16,896 (0.50%) |
|
||||
| `.exe`, Locale | 3,392,512 | 3,377,152 | 15,360 (0.45%) |
|
||||
| `.exe`, Text | 3,392,512 | 2,684,928 | 707,584 (20.9%) |
|
||||
| `.exe`, accessibility bridges | 3,327,488 | 3,311,104 | 16,384 (0.49%) |
|
||||
| `.exe`, Locale | 3,327,488 | 3,312,640 | 14,848 (0.45%) |
|
||||
| `.exe`, Text | 3,327,488 | 2,620,928 | 706,560 (21.2%) |
|
||||
| `.wasm` + `.js`, accessibility bridges | 2,308,781 | 2,305,843 | 2,938 (0.13%) |
|
||||
| `.wasm` + `.js`, Locale | 2,308,781 | 2,295,269 | 13,512 (0.59%) |
|
||||
| `.wasm` + `.js`, Text | 2,308,781 | 1,824,708 | 484,073 (21.0%) |
|
||||
@@ -130,12 +135,12 @@ them.
|
||||
391 KB of tables, and mojibake 19 KB of code and 180 KB of line-breaking and
|
||||
bidirectional data; the `.data` it saves is M PLUS 1p, 1,758,688 bytes.
|
||||
Locale is 15 KB of the executable and 7,581 bytes of catalogs; compiled in
|
||||
(`-DREAKTOR_LOCALE_EMBED=ON`), `showcase.exe` is 3,399,680 bytes.
|
||||
(`-DREAKTOR_LOCALE_EMBED=ON`), `showcase.exe` is 3,335,168 bytes.
|
||||
|
||||
**Text costs memory once it draws.** Medians of private bytes over ten
|
||||
launches: Diagnostics is 12.9 MB with every module and 12.6 MB without Text or
|
||||
without Locale — kb_text_shape's tables are not `const`, so they are committed
|
||||
untouched. Translations is 15.5 MB against 12.6 MB without Text: M PLUS 1p
|
||||
launches: Diagnostics is 12.5 MB with every module, 12.3 MB without Locale and
|
||||
12.1 MB without Text — kb_text_shape's tables are not `const`, so they are
|
||||
committed untouched. Translations is 14.9 MB against 12.3 MB without Text: M PLUS 1p
|
||||
held open, what kb_text_shape parses from it, the glyph texture and the
|
||||
caches.
|
||||
|
||||
@@ -145,16 +150,16 @@ Idle on the Login page.
|
||||
|
||||
| | Windows | Linux | macOS | GhostBSD |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| Committed / private / footprint | **12.6 MB** | **4.3 MB** | **~30 MB** | **5.1 MB** |
|
||||
| Committed / private / footprint | **12.2 MB** | **4.3 MB** | **~30 MB** | **5.1 MB** |
|
||||
| Resident / working set | **29.4 MB** | **11.4 MB** | **33–36 MB** | **11.9 MB** |
|
||||
|
||||
Committed is what the process asked the system to back; resident is what is
|
||||
in RAM, shared library pages included. Windows is today's `showcase`, with
|
||||
every module; the others are the older single-executable build. Idle on
|
||||
Windows, `notepad` is 9.3 MB and `simple`, which links no module, 7.4 MB.
|
||||
Windows, `notepad` is 9.0 MB and `simple`, which links no module, 6.9 MB.
|
||||
|
||||
- **Windows is mostly the system's.** Of the showcase's 12.6 MB, 1.7 MB is
|
||||
Reaktor's own allocations, the largest the glyph atlas (548 KB) and its
|
||||
- **Windows is mostly the system's.** Split before the CSS engine replaced
|
||||
libcss, 1.7 MB of the showcase's 12.6 MB was Reaktor's own allocations, the largest the glyph atlas (548 KB) and its
|
||||
table (281 KB) for eight sizes in two weights. Most of the rest is the heaps
|
||||
of the Windows components it loads: UI Automation, the shell, the input
|
||||
method.
|
||||
|
||||
+26
-26
@@ -3,51 +3,51 @@
|
||||
<rect x="30" y="30" width="715" height="500" rx="14" fill="#353535"/>
|
||||
<text x="70" y="90" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="31" font-weight="600" fill="#ffffff">Memory</text>
|
||||
<text x="70" y="116" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="14" fill="#8e8e8e">private bytes, peak, whole process tree</text>
|
||||
<rect x="99.5" y="448.826" width="46" height="3.17381" fill="#56c7ff"/>
|
||||
<text x="122.5" y="418.826" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">8.9 MB</text>
|
||||
<rect x="99.5" y="448.993" width="46" height="3.00748" fill="#56c7ff"/>
|
||||
<text x="122.5" y="418.993" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">8.5 MB</text>
|
||||
<text x="122.5" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="600" fill="#ffffff">Software</text>
|
||||
<path d="M187.833 452 v-14.7546 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v14.7546 z" fill="#56c7ff"/>
|
||||
<text x="210.833" y="401.245" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">58.2 MB</text>
|
||||
<path d="M187.833 452 v-14.4829 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v14.4829 z" fill="#56c7ff"/>
|
||||
<text x="210.833" y="401.517" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">57.6 MB</text>
|
||||
<text x="210.833" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="600" fill="#ffffff">D3D11</text>
|
||||
<path d="M276.167 452 v-37.2565 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v37.2565 z" fill="#56c7ff"/>
|
||||
<text x="299.167" y="378.743" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">121.3 MB</text>
|
||||
<path d="M276.167 452 v-37.1902 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v37.1902 z" fill="#56c7ff"/>
|
||||
<text x="299.167" y="378.81" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">121.4 MB</text>
|
||||
<text x="299.167" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="600" fill="#ffffff">D3D12</text>
|
||||
<path d="M364.5 452 v-18.7129 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v18.7129 z" fill="#56c7ff"/>
|
||||
<text x="387.5" y="397.287" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">69.3 MB</text>
|
||||
<path d="M364.5 452 v-18.7894 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v18.7894 z" fill="#56c7ff"/>
|
||||
<text x="387.5" y="397.211" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">69.7 MB</text>
|
||||
<text x="387.5" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="600" fill="#ffffff">OpenGL</text>
|
||||
<path d="M452.833 452 v-26.3646 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v26.3646 z" fill="#6e7a82"/>
|
||||
<text x="475.833" y="389.635" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">90.8 MB</text>
|
||||
<path d="M452.833 452 v-41.2121 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v41.2121 z" fill="#6e7a82"/>
|
||||
<text x="475.833" y="374.788" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">132.7 MB</text>
|
||||
<text x="475.833" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="400" fill="#b9b9b9">Flutter</text>
|
||||
<path d="M541.167 452 v-50.1878 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v50.1878 z" fill="#6e7a82"/>
|
||||
<text x="564.167" y="365.812" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">157.6 MB</text>
|
||||
<path d="M541.167 452 v-49.6116 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v49.6116 z" fill="#6e7a82"/>
|
||||
<text x="564.167" y="366.388" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">156.3 MB</text>
|
||||
<text x="564.167" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="400" fill="#b9b9b9">Electron</text>
|
||||
<path d="M629.5 452 v-232 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v232 z" fill="#6e7a82"/>
|
||||
<text x="652.5" y="184" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">667.4 MB</text>
|
||||
<text x="652.5" y="184" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">668.7 MB</text>
|
||||
<text x="652.5" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="400" fill="#b9b9b9">KMP</text>
|
||||
<line x1="60" y1="452.5" x2="715" y2="452.5" stroke="#4a4a4a" stroke-width="1"/>
|
||||
<rect x="755" y="30" width="715" height="500" rx="14" fill="#353535"/>
|
||||
<text x="795" y="90" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="31" font-weight="600" fill="#ffffff">CPU at 60 fps</text>
|
||||
<text x="795" y="116" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="14" fill="#8e8e8e">percent of one core, steady state (3 s to 8 s)</text>
|
||||
<path d="M824.5 452 v-43.7313 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v43.7313 z" fill="#56c7ff"/>
|
||||
<text x="847.5" y="372.269" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">7.0%</text>
|
||||
<path d="M824.5 452 v-48.3305 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v48.3305 z" fill="#56c7ff"/>
|
||||
<text x="847.5" y="367.67" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">6.7%</text>
|
||||
<text x="847.5" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="600" fill="#ffffff">Software</text>
|
||||
<path d="M912.833 452 v-86.3582 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v86.3582 z" fill="#56c7ff"/>
|
||||
<text x="935.833" y="329.642" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">13.0%</text>
|
||||
<path d="M912.833 452 v-102.255 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v102.255 z" fill="#56c7ff"/>
|
||||
<text x="935.833" y="313.744" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">13.4%</text>
|
||||
<text x="935.833" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="600" fill="#ffffff">D3D11</text>
|
||||
<path d="M1001.17 452 v-36.6269 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v36.6269 z" fill="#56c7ff"/>
|
||||
<text x="1024.17" y="379.373" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">6.0%</text>
|
||||
<path d="M1001.17 452 v-39.4106 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v39.4106 z" fill="#56c7ff"/>
|
||||
<text x="1024.17" y="376.589" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">5.6%</text>
|
||||
<text x="1024.17" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="600" fill="#ffffff">D3D12</text>
|
||||
<path d="M1089.5 452 v-39.4687 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v39.4687 z" fill="#56c7ff"/>
|
||||
<text x="1112.5" y="376.531" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">6.4%</text>
|
||||
<path d="M1089.5 452 v-39.0051 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v39.0051 z" fill="#56c7ff"/>
|
||||
<text x="1112.5" y="376.995" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">5.6%</text>
|
||||
<text x="1112.5" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="600" fill="#ffffff">OpenGL</text>
|
||||
<path d="M1177.83 452 v-105.138 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v105.138 z" fill="#6e7a82"/>
|
||||
<text x="1200.83" y="310.862" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">15.6%</text>
|
||||
<path d="M1177.83 452 v-118.068 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v118.068 z" fill="#6e7a82"/>
|
||||
<text x="1200.83" y="297.932" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">15.3%</text>
|
||||
<text x="1200.83" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="400" fill="#b9b9b9">Flutter</text>
|
||||
<path d="M1266.17 452 v-179.491 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v179.491 z" fill="#6e7a82"/>
|
||||
<text x="1289.17" y="236.509" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">26.1%</text>
|
||||
<path d="M1266.17 452 v-152.937 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v152.937 z" fill="#6e7a82"/>
|
||||
<text x="1289.17" y="263.063" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">19.6%</text>
|
||||
<text x="1289.17" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="400" fill="#b9b9b9">Electron</text>
|
||||
<path d="M1354.5 452 v-232 a6 6 0 0 1 6 -6 h34 a6 6 0 0 1 6 6 v232 z" fill="#6e7a82"/>
|
||||
<text x="1377.5" y="184" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">33.5%</text>
|
||||
<text x="1377.5" y="184" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="18" font-weight="600" fill="#ffffff">29.4%</text>
|
||||
<text x="1377.5" y="478" text-anchor="middle" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" font-weight="400" fill="#b9b9b9">KMP</text>
|
||||
<line x1="785" y1="452.5" x2="1440" y2="452.5" stroke="#4a4a4a" stroke-width="1"/>
|
||||
<text x="40" y="562" font-family="Segoe UI, -apple-system, Helvetica Neue, Arial, sans-serif" font-size="15" fill="#b9b9b9">Drawing 64 rotating boxes at 60 fps in an 800×600 window. Lower is better in both panels.</text>
|
||||
|
||||
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
Vendored
-1
Submodule external/lcui deleted from 749f907434
@@ -17,6 +17,7 @@ enum {
|
||||
enum {
|
||||
REAKTOR_LAY_FILL_X = 1u << 0,
|
||||
REAKTOR_LAY_FILL_Y = 1u << 1,
|
||||
REAKTOR_LAY_FILL = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y,
|
||||
REAKTOR_LAY_WRAP = 1u << 2,
|
||||
REAKTOR_LAY_CENTER_X = 1u << 3,
|
||||
REAKTOR_LAY_CENTER_Y = 1u << 4,
|
||||
|
||||
+15
-27
@@ -72,6 +72,7 @@ typedef struct Provider {
|
||||
} Provider;
|
||||
|
||||
static Provider *provider_new(bridge *b, unsigned id);
|
||||
static HRESULT out_fragment(bridge *b, unsigned id, IRawElementProviderFragment **out);
|
||||
|
||||
#define FROM_SIMPLE(p) ((Provider *)((char *)(p) - offsetof(Provider, simple)))
|
||||
#define FROM_FRAGMENT(p) ((Provider *)((char *)(p) - offsetof(Provider, fragment)))
|
||||
@@ -345,12 +346,7 @@ fragment_Navigate(IRawElementProviderFragment *self,
|
||||
switch (dir) {
|
||||
case NavigateDirection_Parent:
|
||||
to = reaktor_snap_parent_in(t, p->id);
|
||||
if (!to) {
|
||||
Provider *r = provider_new(p->b, 0);
|
||||
if (!r) return E_OUTOFMEMORY;
|
||||
*out = &r->fragment;
|
||||
return S_OK;
|
||||
}
|
||||
if (!to) return out_fragment(p->b, 0, out);
|
||||
break;
|
||||
case NavigateDirection_FirstChild:
|
||||
to = reaktor_snap_child_in(t, p->id, 0);
|
||||
@@ -367,13 +363,7 @@ fragment_Navigate(IRawElementProviderFragment *self,
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (!to) return S_OK;
|
||||
{
|
||||
Provider *q = provider_new(p->b, to);
|
||||
if (!q) return E_OUTOFMEMORY;
|
||||
*out = &q->fragment;
|
||||
}
|
||||
return S_OK;
|
||||
return to ? out_fragment(p->b, to, out) : S_OK;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE
|
||||
@@ -471,13 +461,7 @@ root_ElementProviderFromPoint(IRawElementProviderFragmentRoot *self,
|
||||
if (!snap_of(p) || !ClientToScreen(p->b->hwnd, &origin)) return S_OK;
|
||||
hit = reaktor_snap_hit_in(snap_of(p), (float)(x - origin.x),
|
||||
(float)(y - origin.y));
|
||||
if (!hit) return S_OK;
|
||||
{
|
||||
Provider *q = provider_new(p->b, hit);
|
||||
if (!q) return E_OUTOFMEMORY;
|
||||
*out = &q->fragment;
|
||||
}
|
||||
return S_OK;
|
||||
return hit ? out_fragment(p->b, hit, out) : S_OK;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE
|
||||
@@ -489,13 +473,7 @@ root_GetFocus(IRawElementProviderFragmentRoot *self,
|
||||
|
||||
*out = NULL;
|
||||
id = reaktor_snap_focus_in(snap_of(p));
|
||||
if (!id) return S_OK;
|
||||
{
|
||||
Provider *q = provider_new(p->b, id);
|
||||
if (!q) return E_OUTOFMEMORY;
|
||||
*out = &q->fragment;
|
||||
}
|
||||
return S_OK;
|
||||
return id ? out_fragment(p->b, id, out) : S_OK;
|
||||
}
|
||||
|
||||
static IRawElementProviderFragmentRootVtbl g_root_vtbl = {
|
||||
@@ -692,6 +670,16 @@ static IRangeValueProviderVtbl g_range_vtbl = {
|
||||
range_get_SmallChange
|
||||
};
|
||||
|
||||
static HRESULT
|
||||
out_fragment(bridge *b, unsigned id, IRawElementProviderFragment **out)
|
||||
{
|
||||
Provider *q = provider_new(b, id);
|
||||
|
||||
if (!q) return E_OUTOFMEMORY;
|
||||
*out = &q->fragment;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static Provider *
|
||||
provider_new(bridge *b, unsigned id)
|
||||
{
|
||||
|
||||
+4
-10
@@ -13,11 +13,7 @@
|
||||
|
||||
int reaktor_prefers_dark(void)
|
||||
{
|
||||
switch (SDL_GetSystemTheme()) {
|
||||
case SDL_SYSTEM_THEME_DARK: return 1;
|
||||
case SDL_SYSTEM_THEME_LIGHT: return 0;
|
||||
default: return -1;
|
||||
}
|
||||
return SDL_GetSystemTheme() == SDL_SYSTEM_THEME_DARK;
|
||||
}
|
||||
|
||||
#if defined(__APPLE__) && !defined(__EMSCRIPTEN__)
|
||||
@@ -169,7 +165,7 @@ int reaktor_prefers_contrast(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
int reaktor_window_set_dark(SDL_Window *win, int dark)
|
||||
void reaktor_window_set_dark(SDL_Window *win, int dark)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
void *native_window =
|
||||
@@ -182,7 +178,7 @@ int reaktor_window_set_dark(SDL_Window *win, int dark)
|
||||
static int looked_up;
|
||||
int value = dark ? 1 : 0;
|
||||
|
||||
if (!native_window) return 0;
|
||||
if (!native_window) return;
|
||||
if (!looked_up) {
|
||||
void *dll = (void *)LoadLibraryExA("dwmapi.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
if (dll)
|
||||
@@ -190,14 +186,12 @@ int reaktor_window_set_dark(SDL_Window *win, int dark)
|
||||
(HMODULE)dll, "DwmSetWindowAttribute");
|
||||
looked_up = 1;
|
||||
}
|
||||
if (!set_attr) return 0;
|
||||
if (!set_attr) return;
|
||||
|
||||
if (set_attr(native_window, 20, &value, sizeof(value)) != 0)
|
||||
set_attr(native_window, 19, &value, sizeof(value));
|
||||
return 1;
|
||||
#else
|
||||
(void)win;
|
||||
(void)dark;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,6 +7,6 @@ int reaktor_prefers_contrast(void);
|
||||
|
||||
struct SDL_Window;
|
||||
|
||||
int reaktor_window_set_dark(struct SDL_Window *win, int dark);
|
||||
void reaktor_window_set_dark(struct SDL_Window *win, int dark);
|
||||
|
||||
#endif
|
||||
|
||||
+61
-87
@@ -6,7 +6,7 @@
|
||||
#include "locale.h"
|
||||
#include "reaktor/launch.h"
|
||||
#include "lifecycle.h"
|
||||
#include "cssflat.h"
|
||||
#include "css.h"
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "keyboard_web.h"
|
||||
#endif
|
||||
@@ -16,7 +16,7 @@ effective_dark(const App *app)
|
||||
{
|
||||
if (app->theme_mode == REAKTOR_THEME_LIGHT) return 0;
|
||||
if (app->theme_mode == REAKTOR_THEME_DARK) return 1;
|
||||
return reaktor_prefers_dark() > 0;
|
||||
return reaktor_prefers_dark();
|
||||
}
|
||||
|
||||
size_t reaktor_rss[REAKTOR_RSS_STEPS];
|
||||
@@ -91,21 +91,34 @@ reaktor_asset_name(const reaktor_asset *a, const char *fallback)
|
||||
return name;
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#define ON_WEB 1
|
||||
#else
|
||||
#define ON_WEB 0
|
||||
#endif
|
||||
|
||||
static int
|
||||
capturing(const App *app)
|
||||
{
|
||||
return app->shot_path || app->dump_path;
|
||||
}
|
||||
|
||||
static int
|
||||
remembers(const App *app)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
(void)app;
|
||||
return 0;
|
||||
#else
|
||||
return g_launch.remember_window && !app->shot_path && !app->dump_path;
|
||||
#endif
|
||||
return !ON_WEB && g_launch.remember_window && !capturing(app);
|
||||
}
|
||||
|
||||
static int
|
||||
ms_x100(Uint64 from, Uint64 to)
|
||||
{
|
||||
return (int)(100000.0 * (double)(to - from) / (double)SDL_GetPerformanceFrequency());
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_capturing(void)
|
||||
{
|
||||
return g_app && (g_app->shot_path || g_app->dump_path);
|
||||
return g_app && capturing(g_app);
|
||||
}
|
||||
|
||||
reaktor_save
|
||||
@@ -124,23 +137,13 @@ reaktor_key_hook(App *app, const SDL_Event *event)
|
||||
static int
|
||||
starts_hidden(const App *app)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
(void)app;
|
||||
return 0;
|
||||
#else
|
||||
return g_launch.window.hidden && !app->shot_path && !app->dump_path;
|
||||
#endif
|
||||
return !ON_WEB && g_launch.window.hidden && !capturing(app);
|
||||
}
|
||||
|
||||
static int
|
||||
placed(const App *app)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
(void)app;
|
||||
return 0;
|
||||
#else
|
||||
return g_launch.window.centered || remembers(app);
|
||||
#endif
|
||||
return !ON_WEB && (g_launch.window.centered || remembers(app));
|
||||
}
|
||||
|
||||
const char *
|
||||
@@ -170,23 +173,10 @@ reaktor_rss_mark(int step)
|
||||
reaktor_process_memory(&reaktor_rss[step], &reaktor_priv[step]);
|
||||
}
|
||||
|
||||
static char *
|
||||
from_here(const char *path)
|
||||
{
|
||||
char *cwd, *out = NULL;
|
||||
|
||||
if (reaktor_path_absolute(path)) return SDL_strdup(path);
|
||||
cwd = SDL_GetCurrentDirectory();
|
||||
if (!cwd) return NULL;
|
||||
if (SDL_asprintf(&out, "%s%s", cwd, path) < 0) out = NULL;
|
||||
SDL_free(cwd);
|
||||
return out;
|
||||
}
|
||||
|
||||
static void
|
||||
add_fallback(const char *path)
|
||||
{
|
||||
char *full = from_here(path);
|
||||
char *full = reaktor_path_from_cwd(path);
|
||||
|
||||
reaktor_text_add_fallback(full ? full : path);
|
||||
SDL_free(full);
|
||||
@@ -195,7 +185,7 @@ add_fallback(const char *path)
|
||||
static const char *
|
||||
own_here(const char *path)
|
||||
{
|
||||
char *full = from_here(path);
|
||||
char *full = reaktor_path_from_cwd(path);
|
||||
const char *owned = own(full ? full : path);
|
||||
|
||||
SDL_free(full);
|
||||
@@ -250,6 +240,19 @@ log_close(void)
|
||||
g_log = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
pick(const char *v, const char *a, int va, const char *b, int vb, int other)
|
||||
{
|
||||
return SDL_strcmp(v, a) == 0 ? va : SDL_strcmp(v, b) == 0 ? vb : other;
|
||||
}
|
||||
|
||||
static void
|
||||
push_layer(const char **layers, int *n, const char *flag, const char *v)
|
||||
{
|
||||
if (*n < REAKTOR_LAYER_MAX) layers[(*n)++] = own_here(v);
|
||||
else SDL_Log("%s: four at most; %s is not read", flag, v);
|
||||
}
|
||||
|
||||
static int
|
||||
take_flags(App *app, int argc, char **argv)
|
||||
{
|
||||
@@ -263,27 +266,17 @@ take_flags(App *app, int argc, char **argv)
|
||||
|
||||
if (v && SDL_strcmp(a, "--shot") == 0) { app->shot_path = v; i++; }
|
||||
else if (v && SDL_strcmp(a, "--aa") == 0) {
|
||||
g_launch.anti_aliasing = SDL_strcmp(v, "on") == 0 ? REAKTOR_AA_ON
|
||||
: SDL_strcmp(v, "off") == 0 ? REAKTOR_AA_OFF
|
||||
: REAKTOR_AA_AUTO;
|
||||
g_launch.anti_aliasing = (reaktor_aa)pick(v, "on", REAKTOR_AA_ON, "off",
|
||||
REAKTOR_AA_OFF, REAKTOR_AA_AUTO);
|
||||
i++;
|
||||
}
|
||||
else if (v && SDL_strcmp(a, "--console") == 0) {
|
||||
g_launch.console = SDL_strcmp(v, "debug") == 0 ? REAKTOR_CONSOLE_DEBUG
|
||||
: SDL_strcmp(v, "parent") == 0 ? REAKTOR_CONSOLE_PARENT
|
||||
: REAKTOR_CONSOLE_NONE;
|
||||
i++;
|
||||
}
|
||||
else if (v && SDL_strcmp(a, "--css") == 0) {
|
||||
if (g_cli_css_n < REAKTOR_LAYER_MAX) g_cli_css[g_cli_css_n++] = own_here(v);
|
||||
else SDL_Log("--css: four at most; %s is not read", v);
|
||||
i++;
|
||||
}
|
||||
else if (v && SDL_strcmp(a, "--icons") == 0) {
|
||||
if (g_cli_icon_n < REAKTOR_LAYER_MAX) g_cli_icons[g_cli_icon_n++] = own_here(v);
|
||||
else SDL_Log("--icons: four at most; %s is not read", v);
|
||||
g_launch.console = (reaktor_console)pick(v, "debug", REAKTOR_CONSOLE_DEBUG, "parent",
|
||||
REAKTOR_CONSOLE_PARENT, REAKTOR_CONSOLE_NONE);
|
||||
i++;
|
||||
}
|
||||
else if (v && SDL_strcmp(a, "--css") == 0) { push_layer(g_cli_css, &g_cli_css_n, a, v); i++; }
|
||||
else if (v && SDL_strcmp(a, "--icons") == 0) { push_layer(g_cli_icons, &g_cli_icon_n, a, v); i++; }
|
||||
else if (v && SDL_strcmp(a, "--font") == 0) { g_cli_font = own_here(v); i++; }
|
||||
else if (v && SDL_strcmp(a, "--font-bold") == 0) { g_cli_font_bold = own_here(v); i++; }
|
||||
else if (v && SDL_strcmp(a, "--a11y-dump") == 0) { app->dump_path = v; i++; }
|
||||
@@ -291,14 +284,8 @@ take_flags(App *app, int argc, char **argv)
|
||||
else if (SDL_strcmp(a, "--inspect") == 0) g_inspect_flag = 1;
|
||||
else if (SDL_strcmp(a, "--no-inspector") == 0) g_inspect_flag = -1;
|
||||
else if (SDL_strcmp(a, "--watch-css") == 0) g_watch = 1;
|
||||
else if (v && SDL_strcmp(a, "--motion") == 0) {
|
||||
g_motion_flag = SDL_strcmp(v, "reduce") == 0 ? 1 : SDL_strcmp(v, "full") == 0 ? -1 : 0;
|
||||
i++;
|
||||
}
|
||||
else if (v && SDL_strcmp(a, "--contrast") == 0) {
|
||||
g_contrast_flag = SDL_strcmp(v, "more") == 0 ? 1 : SDL_strcmp(v, "normal") == 0 ? -1 : 0;
|
||||
i++;
|
||||
}
|
||||
else if (v && SDL_strcmp(a, "--motion") == 0) { g_motion_flag = pick(v, "reduce", 1, "full", -1, 0); i++; }
|
||||
else if (v && SDL_strcmp(a, "--contrast") == 0) { g_contrast_flag = pick(v, "more", 1, "normal", -1, 0); i++; }
|
||||
else if (SDL_strcmp(a, "--new-instance") == 0) g_new_instance = 1;
|
||||
else if (v && SDL_strcmp(a, "--renderer") == 0) { app->renderer_pref = v; i++; }
|
||||
else if (v && SDL_strcmp(a, "--video") == 0) { app->video_pref = v; i++; }
|
||||
@@ -309,9 +296,8 @@ take_flags(App *app, int argc, char **argv)
|
||||
else if (v && SDL_strcmp(a, "--lang") == 0) { app->lang_pref = v; i++; }
|
||||
else if (v && SDL_strcmp(a, "--font-fallback") == 0) { add_fallback(v); i++; }
|
||||
else if (v && SDL_strcmp(a, "--theme") == 0) {
|
||||
if (SDL_strcmp(v, "light") == 0) app->theme_mode = REAKTOR_THEME_LIGHT;
|
||||
else if (SDL_strcmp(v, "dark") == 0) app->theme_mode = REAKTOR_THEME_DARK;
|
||||
else app->theme_mode = REAKTOR_THEME_SYSTEM;
|
||||
app->theme_mode = pick(v, "light", REAKTOR_THEME_LIGHT, "dark", REAKTOR_THEME_DARK,
|
||||
REAKTOR_THEME_SYSTEM);
|
||||
i++;
|
||||
} else {
|
||||
argv[n++] = argv[i];
|
||||
@@ -504,8 +490,7 @@ load_theme(App *app)
|
||||
read_roles(app);
|
||||
}
|
||||
t1 = SDL_GetPerformanceCounter();
|
||||
app->style_ms_x100 = (int)(100000.0 * (double)(t1 - t0) /
|
||||
(double)SDL_GetPerformanceFrequency());
|
||||
app->style_ms_x100 = ms_x100(t0, t1);
|
||||
app->card_bg = reaktor_style_token("--background", c)
|
||||
? nk_rgba(c[0], c[1], c[2], c[3]) : nk_rgb(226, 226, 226);
|
||||
if (reaktor_style_token("--text-muted", c))
|
||||
@@ -535,12 +520,6 @@ reaktor_app_wake(const App *app)
|
||||
return SDL_PushEvent(&e);
|
||||
}
|
||||
|
||||
static bool
|
||||
wake_loop(void)
|
||||
{
|
||||
return reaktor_app_wake(NULL);
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
static void
|
||||
web_page_size(int *w, int *h)
|
||||
@@ -597,7 +576,6 @@ static int renderer_is_software(SDL_Renderer *ren) { (void)ren; return 0; }
|
||||
#define HOVER_GAP_MS 50
|
||||
|
||||
Uint64 g_hover_gap_ms = HOVER_GAP_MS;
|
||||
static int g_hover_gap_pinned;
|
||||
|
||||
#define CAL_SKIP 3
|
||||
#define CAL_FRAMES 8
|
||||
@@ -607,7 +585,7 @@ calibrate_hover_gap(App *app)
|
||||
{
|
||||
double now;
|
||||
|
||||
if (g_hover_gap_pinned || app->cal_done) return;
|
||||
if (app->cal_done) return;
|
||||
if (app->cal_frames < CAL_SKIP) { app->cal_frames++; return; }
|
||||
now = reaktor_process_cpu_ms();
|
||||
if (app->cal_frames == CAL_SKIP) app->cal_cpu0 = now;
|
||||
@@ -706,7 +684,7 @@ fail(App *app, const char *what)
|
||||
char msg[512];
|
||||
|
||||
SDL_Log("%s: %s", what, SDL_GetError());
|
||||
if (app->shot_path || app->dump_path) return SDL_APP_FAILURE;
|
||||
if (capturing(app)) return SDL_APP_FAILURE;
|
||||
SDL_snprintf(msg, sizeof(msg), "%s.\n\n%s", what, SDL_GetError());
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, launch_title(), msg, NULL);
|
||||
return SDL_APP_FAILURE;
|
||||
@@ -735,7 +713,7 @@ reaktor_hard_quit(int code)
|
||||
{
|
||||
SDL_SetAtomicInt(&g_exit_code, code);
|
||||
SDL_SetAtomicInt(&g_hard_quit, 1);
|
||||
wake_loop();
|
||||
reaktor_app_wake(NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -801,7 +779,7 @@ app_init(void **appstate, int argc, char *argv[])
|
||||
SDL_SetAppMetadata(g_launch.name, g_launch.version, g_launch.id);
|
||||
/* A later launch hands its files to the running copy and is done. */
|
||||
/* A run for a shot or a dump is a test, and always its own copy. */
|
||||
if (g_launch.single_instance && !g_new_instance && !app->shot_path && !app->dump_path &&
|
||||
if (g_launch.single_instance && !g_new_instance && !capturing(app) &&
|
||||
!reaktor_instance_claim(argc, argv))
|
||||
return SDL_APP_SUCCESS;
|
||||
reaktor_hint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
|
||||
@@ -891,7 +869,6 @@ app_init(void **appstate, int argc, char *argv[])
|
||||
}
|
||||
app->renderer_is_sw =
|
||||
SDL_strcmp(SDL_GetRendererName(app->ren), "software") == 0;
|
||||
app->sw_noaa = 0;
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (g_launch.window.min_w > 0 || g_launch.window.min_h > 0)
|
||||
SDL_SetWindowMinimumSize(app->win,
|
||||
@@ -915,7 +892,6 @@ app_init(void **appstate, int argc, char *argv[])
|
||||
|
||||
app->vsync_on = SDL_SetRenderVSync(app->ren, 1) ? 1 : 0;
|
||||
app->aa_mode = (int)g_launch.anti_aliasing;
|
||||
app->redraw_always = 0;
|
||||
|
||||
SDL_strlcpy(app->frame_rate, "waitevent", sizeof(app->frame_rate));
|
||||
|
||||
@@ -1099,7 +1075,7 @@ reaktor_take_event(App *app, SDL_Event *event)
|
||||
break;
|
||||
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
app->queue.hook_ate = g_launch.key && g_launch.key(app, event);
|
||||
app->queue.hook_ate = reaktor_key_hook(app, event);
|
||||
if (app->queue.hook_ate) return;
|
||||
if (focus_key(app, event)) return;
|
||||
break;
|
||||
@@ -1513,7 +1489,7 @@ reaktor_app_frame(App *app, int win_w, int win_h, const char *title,
|
||||
struct nk_context *ctx = app->ctx;
|
||||
struct nk_rect area = nk_rect(0, 0, (float)win_w, (float)win_h);
|
||||
int is_main = !app->secondary, shot = 0, shown;
|
||||
Uint64 now = SDL_GetTicks(), f, t_build0, t_render0, t_present0, t_end;
|
||||
Uint64 now = SDL_GetTicks(), t_build0, t_render0, t_present0, t_end;
|
||||
|
||||
app->laid_w = win_w;
|
||||
app->laid_h = win_h;
|
||||
@@ -1624,7 +1600,6 @@ reaktor_app_frame(App *app, int win_w, int win_h, const char *title,
|
||||
nk_style_pop_float(ctx);
|
||||
nk_style_pop_vec2(ctx);
|
||||
|
||||
f = SDL_GetPerformanceFrequency();
|
||||
t_render0 = SDL_GetPerformanceCounter();
|
||||
if (same_frame(app, ctx)) {
|
||||
t_present0 = t_end = t_render0;
|
||||
@@ -1645,9 +1620,9 @@ reaktor_app_frame(App *app, int win_w, int win_h, const char *title,
|
||||
|
||||
app->last_draw_ms = SDL_GetTicks();
|
||||
if (is_main && app->first_frame_done) calibrate_hover_gap(app);
|
||||
app->build_ms_x100 = (int)(100000.0 * (double)(t_render0 - t_build0) / (double)f);
|
||||
app->render_ms_x100 = (int)(100000.0 * (double)(t_present0 - t_render0) / (double)f);
|
||||
app->present_ms_x100 = (int)(100000.0 * (double)(t_end - t_present0) / (double)f);
|
||||
app->build_ms_x100 = ms_x100(t_build0, t_render0);
|
||||
app->render_ms_x100 = ms_x100(t_render0, t_present0);
|
||||
app->present_ms_x100 = ms_x100(t_present0, t_end);
|
||||
|
||||
nk_input_begin(ctx);
|
||||
|
||||
@@ -1705,7 +1680,7 @@ app_iterate(void *appstate)
|
||||
|
||||
reaktor_app_size(app, &win_w, &win_h);
|
||||
reaktor_app_due(app, win_w, win_h);
|
||||
if (!app->dirty && !app->redraw_always)
|
||||
if (!app->dirty)
|
||||
return SDL_APP_CONTINUE;
|
||||
if (reaktor_app_frame(app, win_w, win_h, launch_title(), main_page, NULL))
|
||||
return SDL_APP_SUCCESS;
|
||||
@@ -1850,11 +1825,10 @@ reaktor_quit(App *app, int exit_code)
|
||||
void
|
||||
reaktor_request_quit(App *app)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
(void)app;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
SDL_Log("quit is ignored on the web");
|
||||
#else
|
||||
(void)app;
|
||||
push_quit(REAKTOR_QUIT_APP);
|
||||
#endif
|
||||
}
|
||||
|
||||
+5
-5
@@ -151,7 +151,7 @@ kv_list(const char *name)
|
||||
reaktor_list(&(reaktor_list_spec){
|
||||
.name = name, .count = g_rows, .columns = cols, .widths = widths,
|
||||
.column_count = 2, .cell = kv_cell,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -184,7 +184,7 @@ tab_tree(void)
|
||||
reaktor_tree(&(reaktor_tree_spec){
|
||||
.name = "Widgets", .count = g_n, .parent = tree_parent, .label = tree_label,
|
||||
.open = g_open, .selected = &sel,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
if (sel != g_sel_ix && sel >= 0 && sel < g_n) {
|
||||
g_sel = g_node[sel].id;
|
||||
g_sel_ix = sel;
|
||||
@@ -311,7 +311,7 @@ tab_style(void)
|
||||
row("min", "%.0f x %.0f", st.min_width, st.min_height);
|
||||
row("max", "%.0f x %.0f", st.max_width, st.max_height);
|
||||
row("font", "%dpx%s", st.font_px, st.bold ? " bold" : "");
|
||||
REAKTOR_COLUMN(.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y, .gap = 8.0f) {
|
||||
REAKTOR_COLUMN(.flags = REAKTOR_LAY_FILL, .gap = 8.0f) {
|
||||
kv_list("Style");
|
||||
note("CSS here applies after every other sheet, to this run only.");
|
||||
reaktor_field(&(reaktor_field_spec){
|
||||
@@ -405,7 +405,7 @@ tab_logs(void)
|
||||
reaktor_list(&(reaktor_list_spec){
|
||||
.name = "Log", .count = g_log_rows, .columns = cols, .widths = widths,
|
||||
.column_count = 3, .cell = log_cell,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
|
||||
/* A flat icon beside the tabs; its name is also what the pointer shows. */
|
||||
@@ -457,7 +457,7 @@ page(App *app, struct reaktor_context *ctx, int w, int h, void *user)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
REAKTOR_COLUMN(.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y, .gap = 8.0f) {
|
||||
REAKTOR_COLUMN(.flags = REAKTOR_LAY_FILL, .gap = 8.0f) {
|
||||
switch (g_tab) {
|
||||
case TAB_TREE: tab_tree(); break;
|
||||
case TAB_BOX: tab_box(); break;
|
||||
|
||||
+1
-10
@@ -61,16 +61,7 @@ message(int argc, char **argv, char **out, Uint32 *out_len)
|
||||
|
||||
for (i = 1; i < argc && count < INSTANCE_PATHS_MAX; i++) {
|
||||
if (!argv[i] || !*argv[i]) continue;
|
||||
if (reaktor_path_absolute(argv[i])) {
|
||||
abs[count] = SDL_strdup(argv[i]);
|
||||
} else {
|
||||
char *cwd = SDL_GetCurrentDirectory();
|
||||
|
||||
abs[count] = NULL;
|
||||
if (cwd && SDL_asprintf(&abs[count], "%s%s", cwd, argv[i]) < 0) abs[count] = NULL;
|
||||
SDL_free(cwd);
|
||||
}
|
||||
if (!abs[count]) continue;
|
||||
if (!(abs[count] = reaktor_path_from_cwd(argv[i]))) continue;
|
||||
total += (Uint32)(sizeof(Uint32) + SDL_strlen(abs[count]));
|
||||
count++;
|
||||
}
|
||||
|
||||
+3
-10
@@ -133,8 +133,8 @@ to_points(const App *m)
|
||||
return reaktor_scale() / (d > 0.0f ? d : 1.0f);
|
||||
}
|
||||
|
||||
static int
|
||||
open_window(const reaktor_window *spec, const struct nk_rect *popup)
|
||||
int
|
||||
reaktor_window_spawn(const reaktor_window *spec, const struct nk_rect *popup)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
(void)spec; (void)popup;
|
||||
@@ -190,7 +190,6 @@ open_window(const reaktor_window *spec, const struct nk_rect *popup)
|
||||
a->win_id = SDL_GetWindowID(a->win);
|
||||
SDL_SetRenderVSync(a->ren, 1);
|
||||
a->renderer_is_sw = SDL_strcmp(SDL_GetRendererName(a->ren), "software") == 0;
|
||||
a->sw_noaa = m->sw_noaa;
|
||||
a->aa_mode = m->aa_mode;
|
||||
a->font_face = m->font_face;
|
||||
a->font_face_bold = m->font_face_bold;
|
||||
@@ -231,13 +230,7 @@ int
|
||||
reaktor_window_open(App *app, const reaktor_window *spec)
|
||||
{
|
||||
(void)app;
|
||||
return open_window(spec, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_window_spawn(const reaktor_window *spec, const struct nk_rect *popup)
|
||||
{
|
||||
return open_window(spec, popup);
|
||||
return reaktor_window_spawn(spec, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -329,7 +329,7 @@ page_shell(App *app, struct reaktor_context *ctx, int win_w, int win_h)
|
||||
.heap = &g.text, .heap_cap = &g.cap, .len = &g.len,
|
||||
.name = "Document", .multiline = 1, .line_numbers = 1,
|
||||
.box = { .ml = 6.0f, .mr = 6.0f, .mt = 2.0f, .mb = 3.0f,
|
||||
.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.flags = REAKTOR_LAY_FILL } });
|
||||
|
||||
REAKTOR_ROW(.h = STATUS_H, .flags = REAKTOR_LAY_FILL_X) {
|
||||
SDL_snprintf(line, sizeof(line), "%s%s - %d characters - %s",
|
||||
|
||||
@@ -377,7 +377,7 @@ fx_demo(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
|
||||
REAKTOR_COLUMN(.gap = 6.0f) REAKTOR_ROW(.h = 120.0f, .gap = 12.0f, .flags = REAKTOR_LAY_FILL_X) {
|
||||
for (i = 0; i < 3; i++)
|
||||
REAKTOR_ROW(.name = what[i], .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {
|
||||
REAKTOR_ROW(.name = what[i], .flags = REAKTOR_LAY_FILL) {
|
||||
struct reaktor_rect r;
|
||||
|
||||
if (reaktor_box_rect(&r)) {
|
||||
@@ -439,7 +439,7 @@ fx_demo(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
|
||||
REAKTOR_COLUMN(.gap = 6.0f) REAKTOR_ROW(.h = 40.0f, .gap = ctx->style.window.spacing.x,
|
||||
.flags = REAKTOR_LAY_FILL_X) {
|
||||
REAKTOR_ROW(.name = "Password", .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {
|
||||
REAKTOR_ROW(.name = "Password", .flags = REAKTOR_LAY_FILL) {
|
||||
float dx = reaktor_anim_shake(a, shake, 26.0f, 22.0f, 0.6f);
|
||||
struct reaktor_rect r;
|
||||
|
||||
@@ -507,7 +507,7 @@ color_demo(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = name[i], .color = "--text-bright",
|
||||
.box = { .w = 74.0f, .flags = REAKTOR_LAY_CENTER_Y } });
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL) {
|
||||
if (reaktor_box_rect(&r)) {
|
||||
struct reaktor_command_buffer *cv = reaktor_window_get_canvas(ctx);
|
||||
int n = (int)(r.w / 4.0f), j;
|
||||
@@ -566,7 +566,7 @@ text_demo(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = name[i], .color = "--text-bright",
|
||||
.box = { .w = 74.0f, .flags = REAKTOR_LAY_CENTER_Y } });
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL) {
|
||||
struct reaktor_anim_text_stagger_opts o = reaktor_anim_text_stagger_opts_default();
|
||||
float t = 1.0f;
|
||||
struct reaktor_rect r;
|
||||
@@ -635,8 +635,7 @@ page_animation(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = stop_name[i],
|
||||
.accent = (unsigned char)(s->anim_slot == i),
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } }))
|
||||
.box = { .flags = REAKTOR_LAY_FILL } }))
|
||||
s->anim_slot = i;
|
||||
}
|
||||
|
||||
@@ -645,7 +644,7 @@ page_animation(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = "instant", .color = "--text-muted",
|
||||
.box = { .w = 74.0f, .flags = REAKTOR_LAY_CENTER_Y } });
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL) {
|
||||
struct reaktor_rect r;
|
||||
if (reaktor_box_rect(&r))
|
||||
track_at(app, ctx, r, stop[s->anim_slot], 0);
|
||||
@@ -656,7 +655,7 @@ page_animation(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = "eased", .color = "--text-bright",
|
||||
.box = { .w = 74.0f, .flags = REAKTOR_LAY_CENTER_Y } });
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL) {
|
||||
unsigned id = reaktor_box_id();
|
||||
float where = reaktor_animate(id, 0, stop[s->anim_slot],
|
||||
ms, curve);
|
||||
@@ -672,7 +671,7 @@ page_animation(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = kind[i], .color = "--text-bright",
|
||||
.box = { .w = 74.0f, .flags = REAKTOR_LAY_CENTER_Y } });
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL) {
|
||||
unsigned id = reaktor_box_id();
|
||||
float to = stop[s->anim_slot];
|
||||
float where = reaktor_anim_tween_float(reaktor_anim(app), id, 0, to, 0.6f,
|
||||
@@ -738,8 +737,7 @@ page_animation(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
.fill = reaktor_token(on ? "--background-hover"
|
||||
: "--background-alt",
|
||||
reaktor_rgb(48, 48, 48)),
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } }))
|
||||
.box = { .flags = REAKTOR_LAY_FILL } }))
|
||||
s->anim_curve = i;
|
||||
|
||||
if (reaktor_box_rect(&r))
|
||||
@@ -768,7 +766,7 @@ page_animation(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
struct reaktor_colorf lit = reaktor_color_cf(reaktor_accent_color(app));
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
REAKTOR_ROW(.name = word[i], .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {
|
||||
REAKTOR_ROW(.name = word[i], .flags = REAKTOR_LAY_FILL) {
|
||||
struct reaktor_rect r;
|
||||
|
||||
if (reaktor_box_rect(&r)) {
|
||||
|
||||
@@ -73,16 +73,13 @@ page_buttons(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
.gap = ctx->style.window.spacing.x) {
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Default",
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } })) s->presses++;
|
||||
.box = { .flags = REAKTOR_LAY_FILL } })) s->presses++;
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Primary", .accent = 1,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } })) s->presses++;
|
||||
.box = { .flags = REAKTOR_LAY_FILL } })) s->presses++;
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "With icon", .icon = "key-outline",
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } })) s->presses++;
|
||||
.box = { .flags = REAKTOR_LAY_FILL } })) s->presses++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,13 +224,11 @@ page_buttons(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Hold me", .repeat = 1,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } }))
|
||||
.box = { .flags = REAKTOR_LAY_FILL } }))
|
||||
s->repeats++;
|
||||
reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Disabled", .disabled = 1,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ diag_row(App *app, struct reaktor_context *ctx, const char *name,
|
||||
.text = value,
|
||||
.name = "value",
|
||||
.silent = 1,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,33 +75,6 @@ page_diagnostics(App *app, struct reaktor_context *ctx, showcase_state *st)
|
||||
"front, and the new copy exits. --new-instance starts a separate copy "
|
||||
"anyway.");
|
||||
api(app, ctx, ".single_instance / .file_opened / --new-instance");
|
||||
#ifndef __EMSCRIPTEN__
|
||||
REAKTOR_ROW(.h = ROW, .gap = ctx->style.window.spacing.x) {
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Launch the showcase again, with a file",
|
||||
.name = "Launch again", .box = { .w = 340.0f } })) {
|
||||
char exe[1024];
|
||||
const char *base = SDL_GetBasePath();
|
||||
const char *args[3];
|
||||
SDL_Process *p;
|
||||
|
||||
SDL_snprintf(exe, sizeof exe, "%sshowcase%s", base ? base : "",
|
||||
#ifdef _WIN32
|
||||
".exe"
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
);
|
||||
args[0] = exe;
|
||||
args[1] = exe;
|
||||
args[2] = NULL;
|
||||
p = SDL_CreateProcess(args, false);
|
||||
if (p) SDL_DestroyProcess(p);
|
||||
else SDL_Log("could not launch %s: %s", exe, SDL_GetError());
|
||||
}
|
||||
reaktor_soak();
|
||||
}
|
||||
#endif
|
||||
SDL_snprintf(v, sizeof v, "%d, the last %s", st->handed,
|
||||
st->handed ? st->file_pick : "none yet");
|
||||
REAKTOR_ROW(.h = ROW_SMALL) {
|
||||
@@ -181,7 +153,7 @@ page_diagnostics(App *app, struct reaktor_context *ctx, showcase_state *st)
|
||||
}
|
||||
|
||||
section(app, ctx, "Style and text",
|
||||
"The stylesheets are parsed by LCUI's libcss on every theme "
|
||||
"The stylesheets are parsed by Reaktor's own CSS engine on every theme "
|
||||
"change, and the font atlas is baked per size at the display's "
|
||||
"scale. The system's reduced motion and contrast reach the sheets as "
|
||||
"@media queries, and with --watch-css a sheet saved on disk restyles "
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
static const char *const g_grid[7][3] = {
|
||||
{ "SDL3", "Zlib", "window, input, renderer, main loop" },
|
||||
{ "Nuklear", "MIT/PD", "the widgets and their layout" },
|
||||
{ "LCUI css", "MIT", "parses the stylesheet, computes values" },
|
||||
{ "FreeType", "FTL", "draws the glyphs" },
|
||||
{ "Water.css", "MIT", "the stylesheet itself" },
|
||||
{ "plutosvg", "MIT", "rasterises the icons" },
|
||||
{ "Ionicons", "MIT", "the icons" },
|
||||
@@ -195,8 +195,7 @@ page_display(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
for (i = 0; i < 3; i++)
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = edges[i], .align = (unsigned char)i,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
REAKTOR_ROW(.h = ROW_SMALL, .flags = REAKTOR_LAY_FILL_X,
|
||||
.gap = ctx->style.window.spacing.x) {
|
||||
@@ -204,8 +203,7 @@ page_display(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = tokens[i], .color = tokens[i],
|
||||
.align = (unsigned char)i,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = "A wrapped label breaks between words inside the row "
|
||||
@@ -335,11 +333,11 @@ page_display(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_list(&(reaktor_list_spec){
|
||||
.name = "To do", .count = g_lane_n[0], .cell = lane_cell, .user = (void *)0,
|
||||
.drag = "task", .dropped = lane_dropped, .columns = (const char *const[]){ "To do" },
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_list(&(reaktor_list_spec){
|
||||
.name = "Done", .count = g_lane_n[1], .cell = lane_cell, .user = (void *)1,
|
||||
.drag = "task", .dropped = lane_dropped, .columns = (const char *const[]){ "Done" },
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
REAKTOR_ROW(.h = ROW, .gap = ctx->style.window.spacing.x) {
|
||||
char undo[48], redo[48];
|
||||
@@ -348,11 +346,11 @@ page_display(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
SDL_snprintf(redo, sizeof redo, "Redo %s", reaktor_redo_label(app) ? reaktor_redo_label(app) : "");
|
||||
if (reaktor_button(&(reaktor_button_spec){ .label = undo, .name = "Undo",
|
||||
.disabled = !reaktor_undo_label(app),
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } }))
|
||||
.box = { .flags = REAKTOR_LAY_FILL } }))
|
||||
reaktor_undo(app);
|
||||
if (reaktor_button(&(reaktor_button_spec){ .label = redo, .name = "Redo",
|
||||
.disabled = !reaktor_redo_label(app),
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } }))
|
||||
.box = { .flags = REAKTOR_LAY_FILL } }))
|
||||
reaktor_redo(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,14 +30,12 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
.buf = s->digits, .len = &s->digits_len,
|
||||
.cap = SC_TEXT_CAP, .hint = "Digits only",
|
||||
.filter = reaktor_filter_decimal,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_field(&(reaktor_field_spec){
|
||||
.buf = s->hex, .len = &s->hex_len,
|
||||
.cap = SC_TEXT_CAP, .hint = "Hex only",
|
||||
.filter = reaktor_filter_hex,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,8 +48,7 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
.buf = s->note, .len = &s->note_len, .cap = SC_BOX_CAP,
|
||||
.name = "Notes", .multiline = 1, .line_numbers = 1,
|
||||
.filter = reaktor_filter_default,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,36 +72,30 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_slider(&(reaktor_slider_spec){
|
||||
.name = "Float", .value = &s->slider_f,
|
||||
.lo = 0.0f, .hi = 1.0f, .step = 0.01f,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = fv,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
REAKTOR_ROW(.h = ROW, .flags = REAKTOR_LAY_FILL_X,
|
||||
.gap = ctx->style.window.spacing.x) {
|
||||
reaktor_slider(&(reaktor_slider_spec){
|
||||
.name = "Integer", .ivalue = &s->slider_i,
|
||||
.lo = 0.0f, .hi = 100.0f, .step = 1.0f,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = iv,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
REAKTOR_ROW(.h = ROW, .flags = REAKTOR_LAY_FILL_X,
|
||||
.gap = ctx->style.window.spacing.x) {
|
||||
reaktor_progress(&(reaktor_progress_spec){
|
||||
.name = "Progress", .value = &s->progress, .max = 100,
|
||||
.modifiable = 1,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = "modifiable - drag it",
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
REAKTOR_ROW(.h = 62.0f, .flags = REAKTOR_LAY_FILL_X,
|
||||
.gap = ctx->style.window.spacing.x) {
|
||||
@@ -128,18 +119,15 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_property(&(reaktor_property_spec){
|
||||
.label = "Columns:", .ivalue = &s->prop_i,
|
||||
.lo = 1, .hi = 24, .step = 1, .grain = 0.25f,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_property(&(reaktor_property_spec){
|
||||
.label = "Stroke:", .fvalue = &s->prop_f,
|
||||
.lo = 0.25, .hi = 8.0, .step = 0.05, .grain = 0.01f,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_property(&(reaktor_property_spec){
|
||||
.label = "Ratio:", .dvalue = &s->prop_d,
|
||||
.lo = 0.0, .hi = 100.0, .step = 0.25, .grain = 0.05f,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
REAKTOR_ROW(.h = ROW, .gap = ctx->style.window.spacing.x) {
|
||||
static const char *const quality[] = { "Low", "Medium", "High", "Best" };
|
||||
@@ -149,11 +137,11 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
|
||||
reaktor_spinner(&(reaktor_spinner_spec){
|
||||
.label = "Quality:", .items = quality, .count = 4, .chosen = &s->spin_q,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_spinner(&(reaktor_spinner_spec){
|
||||
.label = "Day:", .items = days, .count = 7, .chosen = &s->spin_d,
|
||||
.wrap = 1,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +156,13 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
REAKTOR_ROW(.h = ROW, .gap = ctx->style.window.spacing.x) {
|
||||
reaktor_date_pick(&(reaktor_date_spec){
|
||||
.name = "Date", .year = &s->date_y, .month = &s->date_m, .day = &s->date_d,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_time_pick(&(reaktor_time_spec){
|
||||
.name = "Time", .hour = &s->time_h, .minute = &s->time_m,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_time_pick(&(reaktor_time_spec){
|
||||
.name = "Time, 12-hour", .hour = &s->time12_h, .minute = &s->time12_m,
|
||||
.clock12 = 1, .box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.clock12 = 1, .box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
|
||||
section(app, ctx, "Combo boxes",
|
||||
@@ -193,8 +181,7 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
.flags = REAKTOR_LAY_FILL_X) {
|
||||
REAKTOR_COMBO(.label = sizes[s->combo_size], .name = "Size",
|
||||
.body_h = 130.0f,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y }) {
|
||||
.box = { .flags = REAKTOR_LAY_FILL }) {
|
||||
reaktor_layout_row_dynamic(ctx, 26.0f, 1);
|
||||
for (i = 0; i < 3; i++)
|
||||
if (reaktor_combo_item(sizes[i], i == s->combo_size))
|
||||
@@ -203,8 +190,7 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
REAKTOR_COMBO(.label = sizes[s->combo_symbol],
|
||||
.name = "Size, with a symbol",
|
||||
.body_h = 130.0f, .disc = 1,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y }) {
|
||||
.box = { .flags = REAKTOR_LAY_FILL }) {
|
||||
reaktor_layout_row_dynamic(ctx, 26.0f, 1);
|
||||
for (i = 0; i < 3; i++)
|
||||
if (reaktor_combo_item(sizes[i], i == s->combo_symbol))
|
||||
@@ -217,8 +203,7 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
|
||||
REAKTOR_COMBO(.name = "Tint", .body_h = 150.0f,
|
||||
.swatch = &tint,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y }) {
|
||||
.box = { .flags = REAKTOR_LAY_FILL }) {
|
||||
reaktor_layout_row_dynamic(ctx, 26.0f, 1);
|
||||
reaktor_hot_follow(app, reaktor_widget_bounds(ctx), 0);
|
||||
reaktor_property_float(ctx, "R:", 0.0f, &s->tint.r, 1.0f,
|
||||
@@ -232,8 +217,7 @@ page_inputs(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
}
|
||||
REAKTOR_COMBO(.label = "Anything at all",
|
||||
.name = "Anything at all", .body_h = 130.0f,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y }) {
|
||||
.box = { .flags = REAKTOR_LAY_FILL }) {
|
||||
reaktor_layout_row_dynamic(ctx, 26.0f, 1);
|
||||
reaktor_text_label(ctx, "A combo is just a popup",
|
||||
REAKTOR_TEXT_LEFT);
|
||||
|
||||
@@ -126,17 +126,17 @@ page_layout(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
|
||||
REAKTOR_ROW(.h = 3.0f * ROW) {
|
||||
REAKTOR_COLUMN(.weight = split,
|
||||
.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y)
|
||||
.flags = REAKTOR_LAY_FILL)
|
||||
reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Left",
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
reaktor_splitter(&(reaktor_splitter_spec){ .value = &split,
|
||||
.name = "Split" });
|
||||
REAKTOR_COLUMN(.weight = 1.0f - split,
|
||||
.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y)
|
||||
.flags = REAKTOR_LAY_FILL)
|
||||
reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Right",
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -610,8 +610,7 @@ page_popups(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_box_rect(&trigger);
|
||||
reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Right-click anywhere on this button",
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
if (reaktor_contextual_begin(ctx, REAKTOR_WINDOW_BORDER, reaktor_vec2(150.0f, reaktor_menu_height(3)),
|
||||
trigger)) {
|
||||
@@ -655,18 +654,16 @@ page_popups(App *app, struct reaktor_context *ctx, showcase_state *s)
|
||||
reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Hover for a plain tooltip",
|
||||
.tooltip = "A one-line tooltip.",
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {
|
||||
REAKTOR_ROW(.flags = REAKTOR_LAY_FILL) {
|
||||
b = reaktor_rect(0, 0, 0, 0);
|
||||
reaktor_box_rect(&b);
|
||||
reaktor_hot_follow(app, b, 1);
|
||||
ctx->last_widget_state = 0;
|
||||
reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Hover for a laid-out one",
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
if (ctx->last_widget_state & REAKTOR_WIDGET_STATE_HOVER) tip = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,19 @@ static void
|
||||
rule_says(const char *selector)
|
||||
{
|
||||
reaktor_style st;
|
||||
char line[320];
|
||||
char line[320], bg[16] = "transparent";
|
||||
|
||||
reaktor_style_get(selector, &st);
|
||||
if (st.bg[3])
|
||||
SDL_snprintf(bg, sizeof(bg), "#%02x%02x%02x", st.bg[0], st.bg[1], st.bg[2]);
|
||||
if (st.matched)
|
||||
SDL_snprintf(line, sizeof(line),
|
||||
"%s is #%02x%02x%02x on #%02x%02x%02x, corners %.0f, "
|
||||
"%s is #%02x%02x%02x on %s, corners %.0f, "
|
||||
"border %.0f, padding %.1f %.1f %.1f %.1f, type %dpx, "
|
||||
"box %.0fx%.0f min %.0fx%.0f max %.0fx%.0f, "
|
||||
"margin %.1f %.1f %.1f %.1f, "
|
||||
"line %.1f",
|
||||
selector, st.fg[0], st.fg[1], st.fg[2],
|
||||
st.bg[0], st.bg[1], st.bg[2],
|
||||
selector, st.fg[0], st.fg[1], st.fg[2], bg,
|
||||
(double)st.rounding, (double)st.border,
|
||||
(double)st.pad[REAKTOR_SIDE_TOP],
|
||||
(double)st.pad[REAKTOR_SIDE_RIGHT],
|
||||
|
||||
@@ -128,7 +128,7 @@ splash_page(App *app, struct reaktor_context *ctx, int w, int h, void *user)
|
||||
credit(cv, reaktor_font(app, 30, 1), "Reaktor", 164.0f, w, ink, name);
|
||||
SDL_snprintf(line, sizeof line, "version %s", reaktor_version());
|
||||
credit(cv, reaktor_font(app, 15, 0), line, 204.0f, w, muted, name);
|
||||
SDL_snprintf(line, sizeof line, "SDL %d.%d.%d \xC2\xB7 Nuklear \xC2\xB7 NukAnim \xC2\xB7 LCUI \xC2\xB7 plutosvg",
|
||||
SDL_snprintf(line, sizeof line, "SDL %d.%d.%d \xC2\xB7 Nuklear \xC2\xB7 NukAnim \xC2\xB7 FreeType \xC2\xB7 plutosvg",
|
||||
SDL_VERSIONNUM_MAJOR(v), SDL_VERSIONNUM_MINOR(v), SDL_VERSIONNUM_MICRO(v));
|
||||
credit(cv, reaktor_font(app, 12, 0), line, 250.0f, w, muted, tag);
|
||||
credit(cv, reaktor_font(app, 12, 0), "Onlay \xC2\xB7 mojibake \xC2\xB7 kb_text_shape \xC2\xB7 Water.css",
|
||||
@@ -383,8 +383,7 @@ login_card(App *app, struct reaktor_context *ctx, float body_x, float body_w,
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = "Proceed with login",
|
||||
.style = "h4",
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .flags = REAKTOR_LAY_FILL } });
|
||||
}
|
||||
|
||||
reaktor_field(&(reaktor_field_spec){
|
||||
|
||||
+271
-116
@@ -2,37 +2,51 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cssflat.h"
|
||||
#include "css.h"
|
||||
#include "test.h"
|
||||
|
||||
#define ok test_ok
|
||||
#define check test_eq
|
||||
|
||||
static const char g_sheet[] =
|
||||
"input:not([type=\"a\"]):not([type=\"b\"]) { color: #ff0000; }\n"
|
||||
"select:not([type=\"a\"]):not([type=\"b\"]) { color: #ff0000; }\n"
|
||||
"a.x.x { color: #00ff00; }\n"
|
||||
"a:hover:hover { color: #00ff00; }\n"
|
||||
"button.x:hover, input[type=\"range\"] { color: #0000ff; }\n"
|
||||
"button:enabled:hover { color: #123456; }\n"
|
||||
"button[disabled] { color: #654321; }\n"
|
||||
"p { padding: calc(1.5 * 8px) calc(8px / 2); top: calc(0px - 8px); "
|
||||
"p { padding: calc(1.5 * 8px) calc(8px / 2); "
|
||||
"margin: calc(2 * (3px + 1px)); width: calc(100% - 2 * 8px); }\n"
|
||||
"q { background-image: url(data:image/svg+xml;base64,AAAA); color: #010203; }\n"
|
||||
"q.v { content: \"a value longer than the engine token\"; color: #040506; }\n"
|
||||
".a-selector-longer-than-the-engines-token, u { color: #070809; }\n"
|
||||
"q.v { content: \"a value longer than any token the old engine held\"; color: #040506; }\n"
|
||||
".a-selector-longer-than-any-token-the-old-engine-held, u { color: #070809; }\n"
|
||||
"b { border: thin solid #010101; border-left: medium; border-top-width: thick; }\n"
|
||||
"i { border-style: thin-ish; }\n"
|
||||
"s { border: unset; }\n"
|
||||
"u.x { border: inherit; color: #0a0b0c; }\n"
|
||||
"a.y { border-top: 2px dotted #0d0e0f !important; }\n"
|
||||
"a.y.z { border-top: 1px solid #ffffff; }\n"
|
||||
"em { color: color-mix(in srgb, rgb(255 0 0 / 50%) 50%, red); "
|
||||
"background-color: color-mix(in srgb, hsl(120, 100%, 50%), black); "
|
||||
"border-top-color: color-mix(in srgb, #ff000080, rgba(0, 0, 255, 1)); }\n"
|
||||
":root { --slash: /; }\n"
|
||||
":root { --slash: /; --accent: #0a1b2c; --mixed: color-mix(in srgb, var(--accent), white 0%); }\n"
|
||||
"dl { background: url(https://x/a.png); color: #111111; }\n"
|
||||
"dt { b: x//y; color: #121212; }\n"
|
||||
"dd { b: {}x; color: #131313; }\n"
|
||||
"dfn { b: var(--slash)*x; color: #141414; }\n"
|
||||
"a[href^=\"//\"], kbd { color: #151515; }\n";
|
||||
"a[href^=\"//\"], kbd { color: #151515; }\n"
|
||||
"ol { color: #200000; }\n"
|
||||
"ol { color: #200001; }\n"
|
||||
"ol.k { color: #200002; }\n"
|
||||
"ol { color: #200003 !important; padding: 1px; padding: 2px; }\n"
|
||||
"nav .item { color: #300000; }\n"
|
||||
"#\\66oo, .a\\:b, [data-x=\"\\31 2\"] { color: #252525; }\n"
|
||||
"nav > .item { margin: 4px; }\n"
|
||||
"html { font-size: 20px; }\n"
|
||||
"body { font-size: 0.8rem; }\n"
|
||||
"h1 { font-size: 2em; padding: 1rem; font-weight: 600; opacity: 50%; }\n"
|
||||
"h2 { font-size: 150%; line-height: 24px; border: 2px solid; color: #405060; }\n"
|
||||
"h3 { background: var(--accent); border-top-color: currentcolor; color: #010101; }\n";
|
||||
|
||||
static const char g_media[] =
|
||||
"@media (prefers-color-scheme: dark) { h1 { color: #000001; } }\n"
|
||||
@@ -77,6 +91,49 @@ generated(const char *name)
|
||||
s = append(s, "1px");
|
||||
s = repeat(s, ")", 40);
|
||||
s = append(s, "); color: #161616; }\n");
|
||||
} else if (strcmp(name, "open.css") == 0) {
|
||||
s = append(s, "p { color: #222222; q { color: \"x");
|
||||
} else if (strcmp(name, "after.css") == 0) {
|
||||
s = append(s, "kbd { color: #232323; }\n");
|
||||
} else if (strcmp(name, "late.css") == 0) {
|
||||
s = append(s, "h1 { content: \"@import 'nest.css';\"; color: #242424; }\n"
|
||||
"@import \"nest.css\";\n");
|
||||
} else if (strcmp(name, "vars.css") == 0) {
|
||||
s = append(s, ":root {");
|
||||
for (i = 0; i < 20000; i++) {
|
||||
snprintf(piece, sizeof(piece), " --v%d: #%06x;", i, i);
|
||||
s = append(s, piece);
|
||||
}
|
||||
s = append(s, " }\nh1 { color: var(--v19999); }\n");
|
||||
} else if (strcmp(name, "empty.css") == 0) {
|
||||
s = append(s, ":root { --e0: var(--x,);");
|
||||
for (i = 1; i < 12; i++) {
|
||||
snprintf(piece, sizeof(piece), " --e%d:", i);
|
||||
s = append(s, piece);
|
||||
snprintf(piece, sizeof(piece), " var(--e%d)", i - 1);
|
||||
s = repeat(s, piece, 10);
|
||||
s = append(s, ";");
|
||||
}
|
||||
s = append(s, " }\nabbr { color: var(--e11) red; background-color: #1b1b1b; }\n");
|
||||
} else if (strcmp(name, "themes.css") == 0) {
|
||||
s = append(s, ":root { --c: #00ff00; } :root[data-theme=dark] { --c: #ff0000; }\n"
|
||||
":root:not([data-theme=\"dark\"]) { --d: #0000ff; }\n"
|
||||
"h1 { color: var(--c); }\n");
|
||||
} else if (strcmp(name, "sizes.css") == 0) {
|
||||
s = append(s, "body { font-size: 0.5rem; } html { font-size: 20px; }\n"
|
||||
"h1 { font-size: 1em; padding: 1rem; }\n");
|
||||
} else if (strcmp(name, "twice.css") == 0) {
|
||||
s = append(s, "body { font-size: 2em; } body { font-size: 2em; }\n"
|
||||
":root { font-size: 30px !important; } html { font-size: 10px; }\n"
|
||||
"h1 { font-size: 1em; padding: 1rem; }\n");
|
||||
} else if (strcmp(name, "values.css") == 0) {
|
||||
s = append(s, "p { padding: medium thin; }\n"
|
||||
"q { background: url(x) center / cover #ff0000; }\n"
|
||||
"u { border-top-left-radius: 4px 8px; }\n"
|
||||
"a { color: #ff0000; } a { color: var(--missing); }\n"
|
||||
"s { color: color-mix(in oklch, red, blue); }\n");
|
||||
} else if (strcmp(name, "star.css") == 0) {
|
||||
s = append(s, "* { line-height: 1.5; } h1 { font-size: 30px; }\n");
|
||||
} else if (strcmp(name, "self.css") == 0) {
|
||||
s = repeat(s, "@import \"self.css\";\n", 20);
|
||||
s = append(s, "kbd { color: #171717; }\n");
|
||||
@@ -109,21 +166,6 @@ generated(const char *name)
|
||||
return s;
|
||||
}
|
||||
|
||||
static char *
|
||||
flat1(const char *name)
|
||||
{
|
||||
return reaktor_css_flatten(&name, 1, "light", 511, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
count(const char *s, const char *what)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
while ((s = strstr(s, what)) != NULL) { n++; s++; }
|
||||
return n;
|
||||
}
|
||||
|
||||
char *
|
||||
reaktor_asset_load(const char *name, size_t *len)
|
||||
{
|
||||
@@ -168,117 +210,230 @@ reaktor_free(void *p)
|
||||
free(p);
|
||||
}
|
||||
|
||||
static int
|
||||
not_twice(const char *css)
|
||||
{
|
||||
const char *p = css, *q;
|
||||
static reaktor_sheet *g;
|
||||
static long g_seen_n;
|
||||
|
||||
while ((p = strstr(p, ":not(")) != NULL) {
|
||||
for (q = p + 5; *q && !strchr(" \t\r\n,{", *q); q++)
|
||||
if (strncmp(q, ":not(", 5) == 0) return 1;
|
||||
p += 5;
|
||||
}
|
||||
return 0;
|
||||
static void
|
||||
seen(const char *path)
|
||||
{
|
||||
(void)path;
|
||||
g_seen_n++;
|
||||
}
|
||||
|
||||
static reaktor_style
|
||||
get(const char *selector)
|
||||
{
|
||||
reaktor_style s;
|
||||
|
||||
reaktor_sheet_style(g, selector, &s);
|
||||
return s;
|
||||
}
|
||||
|
||||
static long
|
||||
rgb(const unsigned char c[4])
|
||||
{
|
||||
return (long)c[0] << 16 | (long)c[1] << 8 | c[2];
|
||||
}
|
||||
|
||||
static long
|
||||
fg(const char *selector)
|
||||
{
|
||||
reaktor_style s = get(selector);
|
||||
|
||||
return s.matched ? rgb(s.fg) : -1;
|
||||
}
|
||||
|
||||
static reaktor_sheet *
|
||||
load1(const char *name, const char *theme)
|
||||
{
|
||||
return reaktor_sheet_load(&name, 1, theme);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
static const char *const test[1] = { "test.css" };
|
||||
static const char *const media[1] = { "media.css" };
|
||||
static const char *const simple[1] = { "external/simplecss/simple.css" };
|
||||
char *out;
|
||||
int i;
|
||||
reaktor_style s;
|
||||
unsigned char c[4];
|
||||
int i;
|
||||
|
||||
out = reaktor_css_flatten(test, 1, "light", 32, NULL);
|
||||
ok("a sheet flattens", out != NULL);
|
||||
if (out) {
|
||||
ok("two :not() in one compound are dropped", !strstr(out, "not("));
|
||||
ok("a class named twice is dropped", !strstr(out, ".x.x"));
|
||||
ok("a pseudo-class named twice is dropped", !strstr(out, ":hover:hover"));
|
||||
ok("the rest of a selector list stays", strstr(out, "button.x:hover") != NULL);
|
||||
ok("an attribute value becomes a class", strstr(out, "input.type-range") != NULL);
|
||||
ok("a bare attribute becomes a class", strstr(out, "button.disabled") != NULL);
|
||||
ok(":enabled is dropped", strstr(out, "button:hover") != NULL && !strstr(out, ":enabled"));
|
||||
ok("calc() over pixels is worked out", strstr(out, "padding: 12px 4px;") != NULL);
|
||||
ok(" with a subtraction", strstr(out, "top: -8px;") != NULL);
|
||||
ok(" and brackets", strstr(out, "margin: 8px;") != NULL);
|
||||
ok("calc() with a percentage is left", strstr(out, "width: calc(100% - 2 * 8px);") != NULL);
|
||||
ok("a value with a ';' is dropped", !strstr(out, "base64") && strstr(out, "#010203"));
|
||||
ok("a value with '//', '/*' or '}' is dropped",
|
||||
strstr(out, "dl {") && !strstr(strstr(out, "dl {"), "/*") &&
|
||||
!strstr(out, "//") && !strstr(out, "{}") &&
|
||||
strstr(out, "#111111") && strstr(out, "#121212") &&
|
||||
strstr(out, "#131313") && strstr(out, "#141414"));
|
||||
ok("a selector with '//' is dropped, the rest of its list kept",
|
||||
strstr(out, "kbd {") && strstr(out, "#151515"));
|
||||
ok("a value past the token is dropped", !strstr(out, "longer") && strstr(out, "#040506"));
|
||||
ok("a selector past the token is dropped", !strstr(out, "a-selector") && strstr(out, "u {"));
|
||||
ok("border keyword widths become lengths",
|
||||
strstr(out, "border-right-width: 1px;") && strstr(out, "border-left-width: 3px;") &&
|
||||
strstr(out, "border-top-width: 5px;"));
|
||||
ok("a border shorthand is spelled out as longhands",
|
||||
!strstr(out, "border: ") && !strstr(out, "border-left: ") &&
|
||||
strstr(out, "border-bottom-style: solid;") &&
|
||||
strstr(out, "border-bottom-color: #010101;"));
|
||||
ok(" with what it leaves out at libcss's own values",
|
||||
strstr(out, "border-left-style: none;") &&
|
||||
strstr(out, "border-left-color: transparent;"));
|
||||
ok("border: unset is no border", strstr(out, "border-top-width: 0px;") != NULL);
|
||||
ok("border: inherit is dropped, the rest of its rule kept",
|
||||
!strstr(out, "inherit") && strstr(out, "#0a0b0c"));
|
||||
ok("!important reaches every longhand",
|
||||
strstr(out, "border-top-style: dotted !important;") &&
|
||||
strstr(out, "border-top-color: #0d0e0f !important;"));
|
||||
ok(" but not inside another word", strstr(out, "thin-ish") != NULL);
|
||||
ok("color-mix() takes the space form, hsl() and names",
|
||||
!strstr(out, "color-mix") && !strstr(out, "hsl("));
|
||||
ok(" and the comma form with a hex alpha", strstr(out, "border-top-color: rgba(") != NULL);
|
||||
free(out);
|
||||
}
|
||||
g = load1("test.css", "light");
|
||||
ok("a sheet loads", g != NULL);
|
||||
|
||||
out = reaktor_css_flatten(media, 1, "light", 0, NULL);
|
||||
check("two :not() in one compound apply", fg("select"), 0xff0000);
|
||||
ok(" but not to what they exclude", fg("select.type-a") != 0xff0000 && fg("select.type-b") != 0xff0000);
|
||||
check("a class named twice matches once", fg("a.x"), 0x00ff00);
|
||||
check("a pseudo-class named twice matches once", fg("a:hover"), 0x00ff00);
|
||||
check("each selector of a list applies", fg("button.x:disabled:hover"), 0x0000ff);
|
||||
check("equal specificity: the later rule wins", fg("button.x:hover"), 0x123456);
|
||||
check("an attribute value reads as a class", fg("input.type-range"), 0x0000ff);
|
||||
check("a bare attribute reads as a class", fg("button.disabled"), 0x654321);
|
||||
check(":enabled holds unless :disabled is asked", fg("button:hover"), 0x123456);
|
||||
ok(" and :disabled skips it", fg("button:disabled:hover") != 0x123456);
|
||||
|
||||
s = get("p");
|
||||
check("calc() over pixels", (long)s.pad[REAKTOR_SIDE_TOP], 12);
|
||||
check(" with a division", (long)s.pad[REAKTOR_SIDE_RIGHT], 4);
|
||||
check(" and brackets", (long)s.margin[REAKTOR_SIDE_LEFT], 8);
|
||||
check("calc() with a percentage is dropped", (long)s.width, 0);
|
||||
|
||||
check("a ';' inside url() stays inside it", fg("q"), 0x010203);
|
||||
check("a long value is read", fg("q.v"), 0x040506);
|
||||
check("a long selector is read", fg(".a-selector-longer-than-any-token-the-old-engine-held"), 0x070809);
|
||||
check(" and the rest of its list", fg("u"), 0x070809);
|
||||
|
||||
s = get("b");
|
||||
check("border keyword widths", (long)s.border_w[REAKTOR_SIDE_TOP], 5);
|
||||
check(" thin", (long)s.border_w[REAKTOR_SIDE_RIGHT], 1);
|
||||
check(" a side set without a style has none", (long)s.border_w[REAKTOR_SIDE_LEFT], 0);
|
||||
check(" the shorthand's color", rgb(s.border_col), 0x010101);
|
||||
ok("an invalid border-style is dropped", !get("i").matched);
|
||||
s = get("s");
|
||||
ok("border: unset is no border", s.matched && s.border == 0.0f);
|
||||
check("border: inherit keeps the rest of its rule", fg("u.x"), 0x0a0b0c);
|
||||
s = get("a.y.z");
|
||||
check("!important beats a more specific rule", (long)s.border, 2);
|
||||
check(" with its color", rgb(s.border_col), 0x0d0e0f);
|
||||
|
||||
s = get("em");
|
||||
check("color-mix() with the space form and a weight", rgb(s.fg), 0xff0000);
|
||||
check(" and its alpha", s.fg[3], 191);
|
||||
check("color-mix() with hsl() and names", rgb(s.bg), 0x008000);
|
||||
check("color-mix() with a hex alpha", s.border_col[0], 85);
|
||||
|
||||
check("a declaration of unknown text keeps its rule", fg("dl"), 0x111111);
|
||||
check(" '//' in a value", fg("dt"), 0x121212);
|
||||
check(" a block in a value", fg("dd"), 0x131313);
|
||||
check(" var() of a '/'", fg("dfn"), 0x141414);
|
||||
check("an operator attribute drops only its selector", fg("kbd"), 0x151515);
|
||||
ok(" which matches nothing", fg("a") != 0x151515);
|
||||
ok("background: url() is transparent", get("dl").bg[3] == 0);
|
||||
|
||||
check("!important wins over later rules", fg("ol"), 0x200003);
|
||||
check(" and over more specific ones", fg("ol.k"), 0x200003);
|
||||
check("the later declaration wins in a rule", (long)get("ol").pad[REAKTOR_SIDE_TOP], 2);
|
||||
check("a hex escape in a name", fg("#foo"), 0x252525);
|
||||
check("an escaped character in a name", fg("a.a\\:b"), 0x252525);
|
||||
check("an escape in an attribute value", fg("p.data-x-12"), 0x252525);
|
||||
check("a descendant selector", fg("nav .item"), 0x300000);
|
||||
check(" through another level", fg("nav ul .item"), 0x300000);
|
||||
ok(" not without its ancestor", !get(".item").matched);
|
||||
check("a child selector", (long)get("nav .item").margin[0], 4);
|
||||
check(" not through another level", (long)get("nav ul .item").margin[0], 0);
|
||||
|
||||
s = get("h1");
|
||||
check("em is the body's size", s.font_px, 32);
|
||||
check("rem is the root's size", (long)s.pad[0], 20);
|
||||
check("weight 600 is bold", s.bold, 1);
|
||||
ok("opacity takes a percentage", s.opacity == 0.5f);
|
||||
s = get("h2");
|
||||
check("a percentage font size", s.font_px, 24);
|
||||
check("a line height in pixels", (long)s.line_height, 24);
|
||||
check("a border with no color takes the text's", rgb(s.border_col), 0x405060);
|
||||
s = get("h3");
|
||||
check("background takes a var() color", rgb(s.bg), 0x0a1b2c);
|
||||
check("currentcolor", rgb(s.border_col), 0x010101);
|
||||
ok("a token reads as a color", reaktor_sheet_color(g, "--accent", c) && rgb(c) == 0x0a1b2c);
|
||||
ok(" through var() and color-mix()", reaktor_sheet_color(g, "--mixed", c) && rgb(c) == 0x0a1b2c);
|
||||
ok(" and not when it is no color", !reaktor_sheet_color(g, "--slash", c));
|
||||
ok("a selector that does not parse matches nothing", !get("a + b").matched && !get("").matched);
|
||||
reaktor_sheet_free(g);
|
||||
|
||||
g = load1("media.css", "light");
|
||||
ok("with no preference, only no-preference queries apply",
|
||||
out && strstr(out, "#000003") && !strstr(out, "#000001") && !strstr(out, "#000002") &&
|
||||
!strstr(out, "#000004") && !strstr(out, "#000005") && !strstr(out, "#000006"));
|
||||
free(out);
|
||||
fg("h3") == 3 && fg("h1") < 0 && fg("h2") < 0 && fg("h4") < 0 && fg("h5") < 0 && fg("h6") < 0);
|
||||
reaktor_sheet_free(g);
|
||||
reaktor_css_media(1, 1);
|
||||
out = reaktor_css_flatten(media, 1, "dark", 0, NULL);
|
||||
g = load1("media.css", "dark");
|
||||
ok("reduced motion and more contrast apply theirs",
|
||||
out && strstr(out, "#000001") && strstr(out, "#000002") && !strstr(out, "#000003") &&
|
||||
strstr(out, "#000004") && strstr(out, "#000005") && strstr(out, "#000006"));
|
||||
ok(" but not with a feature not answered here, nor print",
|
||||
out && !strstr(out, "#000007") && !strstr(out, "#000008"));
|
||||
free(out);
|
||||
fg("h1") == 1 && fg("h2") == 2 && fg("h3") < 0 && fg("h4") == 4 && fg("h5") == 5 && fg("h6") == 6);
|
||||
ok(" but not with a feature not answered here, nor print", fg("ol") < 0 && fg("ul") < 0);
|
||||
reaktor_sheet_free(g);
|
||||
reaktor_css_media(0, 0);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
out = reaktor_css_flatten(simple, 1, i ? "dark" : "light", 0, NULL);
|
||||
ok(i ? "Simple.css flattens, dark" : "Simple.css flattens, light",
|
||||
out != NULL && strstr(out, "button") != NULL);
|
||||
ok(" and no compound in it holds two :not()", out != NULL && !not_twice(out));
|
||||
free(out);
|
||||
static const char *const simple[1] = { "external/simplecss/simple.css" };
|
||||
|
||||
g = reaktor_sheet_load(simple, 1, i ? "dark" : "light");
|
||||
ok(i ? "Simple.css loads, dark" : "Simple.css loads, light", g && get("button").matched);
|
||||
reaktor_sheet_free(g);
|
||||
}
|
||||
|
||||
out = flat1("calc.css");
|
||||
g = load1("star.css", "light");
|
||||
check("* applies to everything", (long)(get("h1").line_height + 0.5f), 45);
|
||||
ok(" and matches any selector", get("anything .at all").matched);
|
||||
reaktor_sheet_free(g);
|
||||
g = load1("calc.css", "light");
|
||||
ok("calc() nested past its depth is dropped, the rest of its rule kept",
|
||||
out && !strstr(out, "width") && strstr(out, "#161616"));
|
||||
free(out);
|
||||
out = flat1("self.css");
|
||||
ok("a sheet that imports itself is read once", out && count(out, "#171717") == 1);
|
||||
free(out);
|
||||
out = flat1("fan0.css");
|
||||
ok("imports that fan out stop at the budget", out && strlen(out) < (16u << 20));
|
||||
free(out);
|
||||
out = flat1("nest.css");
|
||||
ok("var() fallbacks nested past the limit are dropped",
|
||||
out && !strstr(out, "red") && strstr(out, "background-color: #191919"));
|
||||
free(out);
|
||||
out = flat1("laughs.css");
|
||||
ok("var() that would grow past the limit is dropped",
|
||||
out && strlen(out) < (1u << 20) && !strstr(out, "var(") &&
|
||||
strstr(out, "#1a1a1a"));
|
||||
free(out);
|
||||
get("dir").width == 0.0f && fg("dir") == 0x161616);
|
||||
reaktor_sheet_free(g);
|
||||
g = load1("self.css", "light");
|
||||
check("a sheet that imports itself loads", fg("kbd"), 0x171717);
|
||||
reaktor_sheet_free(g);
|
||||
g = load1("fan0.css", "light");
|
||||
check("imports that fan out stop at the budget", fg("samp"), 0x181818);
|
||||
reaktor_sheet_free(g);
|
||||
g = load1("nest.css", "light");
|
||||
s = get("var");
|
||||
ok("var() fallbacks nested past the limit are dropped", s.fg[0] == 0 && rgb(s.bg) == 0x191919);
|
||||
reaktor_sheet_free(g);
|
||||
g = load1("laughs.css", "light");
|
||||
s = get("abbr");
|
||||
ok("var() that would grow past the limit is dropped", rgb(s.fg) == 0 && rgb(s.bg) == 0x1a1a1a);
|
||||
reaktor_sheet_free(g);
|
||||
|
||||
reaktor_css_track(seen);
|
||||
{
|
||||
static const char *const pair[2] = { "open.css", "after.css" };
|
||||
|
||||
g = reaktor_sheet_load(pair, 2, "light");
|
||||
check("a sheet left open is closed at its end", fg("p"), 0x222222);
|
||||
check(" and the next sheet still reads", fg("kbd"), 0x232323);
|
||||
reaktor_sheet_free(g);
|
||||
}
|
||||
g_seen_n = 0;
|
||||
g = load1("late.css", "light");
|
||||
check("@import is read only at the top of a sheet", g_seen_n, 1);
|
||||
check(" and not inside a string", fg("h1"), 0x242424);
|
||||
reaktor_sheet_free(g);
|
||||
g_seen_n = 0;
|
||||
g = load1("fan0.css", "light");
|
||||
ok("imports that fan out stop at a count of loads", g_seen_n > 0 && g_seen_n <= 258);
|
||||
reaktor_sheet_free(g);
|
||||
reaktor_css_track(NULL);
|
||||
|
||||
g = load1("vars.css", "light");
|
||||
check("many custom properties load", fg("h1"), 19999);
|
||||
reaktor_sheet_free(g);
|
||||
g = load1("empty.css", "light");
|
||||
s = get("abbr");
|
||||
ok("var() that would expand too often is dropped", rgb(s.fg) == 0 && rgb(s.bg) == 0x1b1b1b);
|
||||
reaktor_sheet_free(g);
|
||||
|
||||
g = load1("themes.css", "light");
|
||||
check("the theme's own variables apply", fg("h1"), 0x00ff00);
|
||||
ok(" and :not() of the other theme", reaktor_sheet_color(g, "--d", c) && rgb(c) == 0x0000ff);
|
||||
reaktor_sheet_free(g);
|
||||
g = load1("themes.css", "dark");
|
||||
check(" the other theme's", fg("h1"), 0xff0000);
|
||||
ok(" without the excluded one", !reaktor_sheet_color(g, "--d", c));
|
||||
reaktor_sheet_free(g);
|
||||
|
||||
g = load1("sizes.css", "light");
|
||||
check("em follows rem whatever the order", get("h1").font_px, 10);
|
||||
check("rem is the root's", (long)get("h1").pad[0], 20);
|
||||
reaktor_sheet_free(g);
|
||||
g = load1("twice.css", "light");
|
||||
check("a size repeated does not compound", get("h1").font_px, 60);
|
||||
check(":root counts, and !important wins", (long)get("h1").pad[0], 30);
|
||||
reaktor_sheet_free(g);
|
||||
|
||||
g = load1("values.css", "light");
|
||||
ok("thin and medium are border widths only", !get("p").matched);
|
||||
check("background past a '/'", rgb(get("q").bg), 0xff0000);
|
||||
check("a corner radius with two values", (long)get("u").radius[0], 4);
|
||||
check("an undefined var() unsets, not skips", fg("a"), 0);
|
||||
ok("color-mix() outside srgb is dropped", !get("s").matched);
|
||||
reaktor_sheet_free(g);
|
||||
|
||||
return test_done("css");
|
||||
}
|
||||
|
||||
+2
-12
@@ -128,12 +128,7 @@ text(const char *what, unsigned mods, SDL_Keycode key, const char *want)
|
||||
{
|
||||
char buf[64];
|
||||
reaktor_chord_text(mods, key, buf, (int)sizeof(buf));
|
||||
if (strcmp(buf, want) != 0) {
|
||||
failures++;
|
||||
printf(" %-52s got \"%s\", wanted \"%s\" FAILED\n", what, buf, want);
|
||||
} else {
|
||||
printf(" %-52s \"%s\"\n", what, buf);
|
||||
}
|
||||
test_str(what, buf, want);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -181,12 +176,7 @@ list(const char *what, int action, int index, const char *want)
|
||||
|
||||
buf[0] = '\0';
|
||||
reaktor_shortcut_text(LIST, LIST_N, action, index, buf, (int)sizeof(buf));
|
||||
if (strcmp(buf, want) != 0) {
|
||||
failures++;
|
||||
printf(" %-52s got \"%s\", wanted \"%s\" FAILED\n", what, buf, want);
|
||||
} else {
|
||||
printf(" %-52s \"%s\"\n", what, buf);
|
||||
}
|
||||
test_str(what, buf, want);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+72
-176
@@ -1,3 +1,4 @@
|
||||
#include <stdarg.h>
|
||||
#include "internal.h"
|
||||
#include "declare.h"
|
||||
#include "anim.h"
|
||||
@@ -20,6 +21,18 @@ note(const char *what)
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void
|
||||
notef(const char *fmt, ...)
|
||||
{
|
||||
char line[600];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
SDL_vsnprintf(line, sizeof line, fmt, ap);
|
||||
va_end(ap);
|
||||
note(line);
|
||||
}
|
||||
|
||||
static int
|
||||
is(const char *mode)
|
||||
{
|
||||
@@ -75,7 +88,6 @@ static void
|
||||
floater_body(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
{
|
||||
static int clicked;
|
||||
char line[32];
|
||||
|
||||
(void)w;
|
||||
if (SDL_strcmp((const char *)user, "Cover") == 0 && !clicked &&
|
||||
@@ -86,8 +98,7 @@ floater_body(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
}
|
||||
nk_layout_row_dynamic(ctx, h > 120 ? 120.0f : 28.0f, 1);
|
||||
if (reaktor_button_label(app, ctx, (const char *)user)) {
|
||||
SDL_snprintf(line, sizeof line, "pressed %s", (const char *)user);
|
||||
note(line);
|
||||
notef("pressed %s", (const char *)user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,10 +172,7 @@ when(void)
|
||||
static void
|
||||
said(const char *what)
|
||||
{
|
||||
char line[64];
|
||||
|
||||
SDL_snprintf(line, sizeof line, "%s %s", what, when());
|
||||
note(line);
|
||||
notef("%s %s", what, when());
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -250,8 +258,7 @@ hold_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
if (g_frames == 4 || g_frames == 17)
|
||||
push_click(app, g_link.x + 10.0f, g_link.y + g_link.h * 0.5f);
|
||||
if (g_frames == 7 || g_frames == 17) {
|
||||
SDL_snprintf(line, sizeof line, "cursor %d", app->want_cursor);
|
||||
note(line);
|
||||
notef("cursor %d", app->want_cursor);
|
||||
}
|
||||
if (g_frames == 7 || g_frames == 12)
|
||||
push_click(app, g_field.x + 20.0f, g_field.y + g_field.h * 0.5f);
|
||||
@@ -338,9 +345,7 @@ hold_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
if (closing && g_frames == 13) reaktor_floater_close(app, g_second);
|
||||
if (g_frames == 16) push_text(app, "b");
|
||||
if (g_frames == 20) {
|
||||
SDL_snprintf(line, sizeof line, "typed '%s', text input %d", buf,
|
||||
(int)SDL_TextInputActive(app->win));
|
||||
note(line);
|
||||
notef("typed '%s', text input %d", buf, (int)SDL_TextInputActive(app->win));
|
||||
}
|
||||
}
|
||||
if (is("hold-toast") || is("hold-toast-page")) {
|
||||
@@ -350,10 +355,7 @@ hold_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
reaktor_toast(app, &(reaktor_toast_spec){ .text = "toast" });
|
||||
if (g_frames == 9) push_text(app, "b");
|
||||
if (g_frames == 13) {
|
||||
SDL_snprintf(line, sizeof line, "typed '%s', text input %d",
|
||||
is("hold-toast") ? g_modal_buf : buf,
|
||||
(int)SDL_TextInputActive(app->win));
|
||||
note(line);
|
||||
notef("typed '%s', text input %d", is("hold-toast") ? g_modal_buf : buf, (int)SDL_TextInputActive(app->win));
|
||||
}
|
||||
}
|
||||
if (g_frames == 26) {
|
||||
@@ -375,7 +377,6 @@ static void
|
||||
window_page(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
{
|
||||
static int frames;
|
||||
char line[96];
|
||||
|
||||
(void)w; (void)h; (void)user;
|
||||
frames++;
|
||||
@@ -387,9 +388,7 @@ window_page(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
push_text(app, "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e\xe3\x81\xae"
|
||||
"\xe3\x83\x86\xe3\x82\xad");
|
||||
if (frames == 10) {
|
||||
SDL_snprintf(line, sizeof line, "window text %d bytes, text input %d",
|
||||
(int)SDL_strlen(g_win_buf), (int)SDL_TextInputActive(app->win));
|
||||
note(line);
|
||||
notef("window text %d bytes, text input %d", (int)SDL_strlen(g_win_buf), (int)SDL_TextInputActive(app->win));
|
||||
reaktor_quit(app, 0);
|
||||
}
|
||||
app->dirty = 1;
|
||||
@@ -403,7 +402,6 @@ static char g_one_buf[16];
|
||||
static void
|
||||
win_page(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
{
|
||||
char line[128];
|
||||
int f = ++g_win_frames, more = f < 30;
|
||||
|
||||
(void)user;
|
||||
@@ -415,11 +413,7 @@ win_page(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
SDL_GetDisplayUsableBounds(SDL_GetDisplayForWindow(app->win), &d);
|
||||
SDL_GetWindowPosition(app->win, &x, &y);
|
||||
SDL_GetWindowSize(app->win, &ww, &wh);
|
||||
SDL_snprintf(line, sizeof line, "borderless %d, utility %d, centered %d",
|
||||
!!(fl & SDL_WINDOW_BORDERLESS), !!(fl & SDL_WINDOW_UTILITY),
|
||||
SDL_abs(x + ww / 2 - (d.x + d.w / 2)) <= 1 &&
|
||||
SDL_abs(y + wh / 2 - (d.y + d.h / 2)) <= 1);
|
||||
note(line);
|
||||
notef("borderless %d, utility %d, centered %d", !!(fl & SDL_WINDOW_BORDERLESS), !!(fl & SDL_WINDOW_UTILITY), SDL_abs(x + ww / 2 - (d.x + d.w / 2)) <= 1 && SDL_abs(y + wh / 2 - (d.y + d.h / 2)) <= 1);
|
||||
reaktor_quit(app, 0);
|
||||
}
|
||||
if (is("win-keys")) {
|
||||
@@ -456,10 +450,7 @@ win_page(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
} else if (is("win-title")) {
|
||||
if (f == 2) reaktor_set_title(app, "Retitled");
|
||||
if (f == 8) {
|
||||
SDL_snprintf(line, sizeof line, "window title '%s', main '%s'",
|
||||
SDL_GetWindowTitle(app->win),
|
||||
SDL_GetWindowTitle(reaktor_main_app()->win));
|
||||
note(line);
|
||||
notef("window title '%s', main '%s'", SDL_GetWindowTitle(app->win), SDL_GetWindowTitle(reaktor_main_app()->win));
|
||||
reaktor_quit(app, 0);
|
||||
}
|
||||
} else if (is("win-theme")) {
|
||||
@@ -470,17 +461,13 @@ win_page(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
reaktor_set_theme(app, want ? REAKTOR_THEME_DARK : REAKTOR_THEME_LIGHT);
|
||||
}
|
||||
if (f == 10) {
|
||||
SDL_snprintf(line, sizeof line, "theme followed: main %s, window %s",
|
||||
reaktor_main_app()->dark == want ? "yes" : "no",
|
||||
app->dark == want ? "yes" : "no");
|
||||
note(line);
|
||||
notef("theme followed: main %s, window %s", reaktor_main_app()->dark == want ? "yes" : "no", app->dark == want ? "yes" : "no");
|
||||
reaktor_quit(app, 0);
|
||||
}
|
||||
} else if (is("win-wake")) {
|
||||
if (f == 5) g_main_at = g_frames;
|
||||
if (f == 30) {
|
||||
SDL_snprintf(line, sizeof line, "main frames +%d", g_frames - g_main_at);
|
||||
note(line);
|
||||
notef("main frames +%d", g_frames - g_main_at);
|
||||
reaktor_quit(app, 0);
|
||||
}
|
||||
} else if (is("win-one-change")) {
|
||||
@@ -493,8 +480,7 @@ win_page(App *app, struct nk_context *ctx, int w, int h, void *user)
|
||||
push_tap(app, SDLK_BACKSPACE);
|
||||
}
|
||||
if (f == 15) {
|
||||
SDL_snprintf(line, sizeof line, "field '%s'", g_one_buf);
|
||||
note(line);
|
||||
notef("field '%s'", g_one_buf);
|
||||
reaktor_quit(app, 0);
|
||||
}
|
||||
} else if (is("win-drag")) {
|
||||
@@ -529,11 +515,8 @@ open_probe_window(App *app)
|
||||
static int SDLCALL
|
||||
report_anim(void *app)
|
||||
{
|
||||
char line[32];
|
||||
|
||||
SDL_Delay(1500);
|
||||
SDL_snprintf(line, sizeof line, "anim %.0f", (double)g_anim);
|
||||
note(line);
|
||||
notef("anim %.0f", (double)g_anim);
|
||||
reaktor_quit((App *)app, 0);
|
||||
return 0;
|
||||
}
|
||||
@@ -541,15 +524,12 @@ report_anim(void *app)
|
||||
static int SDLCALL
|
||||
count_drag(void *app)
|
||||
{
|
||||
char line[64];
|
||||
int at;
|
||||
|
||||
SDL_Delay(1200);
|
||||
at = g_win_frames;
|
||||
SDL_Delay(3300);
|
||||
SDL_snprintf(line, sizeof line, "window frames +%d while dragged",
|
||||
g_win_frames - at);
|
||||
note(line);
|
||||
notef("window frames +%d while dragged", g_win_frames - at);
|
||||
reaktor_quit((App *)app, 0);
|
||||
return 0;
|
||||
}
|
||||
@@ -563,41 +543,39 @@ quit_after(void *app)
|
||||
}
|
||||
|
||||
/* The last frame's tree: this frame's is still being built. */
|
||||
static int
|
||||
press_named(App *app, const char *name)
|
||||
static const reaktor_a11y_node *
|
||||
last_node(App *app, unsigned char role, const char *name)
|
||||
{
|
||||
const reaktor_a11y_node *t = app->a11y.node[1 - app->a11y.front];
|
||||
int n = app->a11y.count[1 - app->a11y.front], i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].role == REAKTOR_A11Y_BUTTON && t[i].name &&
|
||||
SDL_strcmp(t[i].name, name) == 0) {
|
||||
push_click(app, t[i].bounds.x + t[i].bounds.w * 0.5f,
|
||||
t[i].bounds.y + t[i].bounds.h * 0.5f);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
if (t[i].role == role && t[i].name && SDL_strcmp(t[i].name, name) == 0) return &t[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
press_role(App *app, unsigned char role, const char *name)
|
||||
{
|
||||
const reaktor_a11y_node *t = last_node(app, role, name);
|
||||
|
||||
if (t) push_click(app, t->bounds.x + t->bounds.w * 0.5f, t->bounds.y + t->bounds.h * 0.5f);
|
||||
return t != NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
answered(App *app, int button, void *user)
|
||||
{
|
||||
char line[32];
|
||||
|
||||
(void)app; (void)user;
|
||||
SDL_snprintf(line, sizeof line, "answer %d", button);
|
||||
note(line);
|
||||
notef("answer %d", button);
|
||||
}
|
||||
|
||||
static void
|
||||
ticked(App *app, void *user)
|
||||
{
|
||||
static int n;
|
||||
char line[32];
|
||||
|
||||
SDL_snprintf(line, sizeof line, "tick %d %s", ++n,
|
||||
app == reaktor_main_app() ? "main" : "other");
|
||||
note(line);
|
||||
notef("tick %d %s", ++n, app == reaktor_main_app() ? "main" : "other");
|
||||
if (n == 3) reaktor_timer_stop(*(unsigned *)user);
|
||||
}
|
||||
|
||||
@@ -628,16 +606,12 @@ cell(int row, int column, void *user)
|
||||
static int
|
||||
row_shown(App *app, int row)
|
||||
{
|
||||
const reaktor_a11y_node *t = app->a11y.node[1 - app->a11y.front];
|
||||
int n = app->a11y.count[1 - app->a11y.front], i;
|
||||
const reaktor_a11y_node *t;
|
||||
char name[8];
|
||||
|
||||
SDL_snprintf(name, sizeof name, "row %d", row);
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].role == REAKTOR_A11Y_LISTITEM && t[i].name &&
|
||||
SDL_strcmp(t[i].name, name) == 0)
|
||||
return !(t[i].state & REAKTOR_A11Y_OFFSCREEN);
|
||||
return 0;
|
||||
t = last_node(app, REAKTOR_A11Y_LISTITEM, name);
|
||||
return t && !(t->state & REAKTOR_A11Y_OFFSCREEN);
|
||||
}
|
||||
|
||||
static Uint64 g_saved_at;
|
||||
@@ -668,13 +642,12 @@ service_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
static int chosen = -1, said = -1;
|
||||
static float share = 0.5f;
|
||||
int split = is("split-keys") || is("split-vkeys");
|
||||
char line[48];
|
||||
|
||||
(void)ctx;
|
||||
if (is("ask") && g_frames == 2)
|
||||
reaktor_ask(app, &(reaktor_question){ .text = "Save it?", .buttons = buttons,
|
||||
.count = 2, .answered = answered });
|
||||
if (is("ask") && g_frames == 6) note(press_named(app, "Save") ? "pressed" : "no button");
|
||||
if (is("ask") && g_frames == 6) note(press_role(app, REAKTOR_A11Y_BUTTON, "Save") ? "pressed" : "no button");
|
||||
if (is("timer") && g_frames == 2) {
|
||||
repeat = reaktor_timer(app, 50, 1, ticked, &repeat);
|
||||
note(repeat ? "timer on" : "timer refused");
|
||||
@@ -709,40 +682,29 @@ service_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
reaktor_setting_set("launchtest.key", "a=b");
|
||||
reaktor_setting_set("launchtest.gone", "x");
|
||||
reaktor_setting_set("launchtest.gone", NULL);
|
||||
SDL_snprintf(line, sizeof line, "setting %s %s",
|
||||
reaktor_setting("launchtest.key"),
|
||||
reaktor_setting("launchtest.gone") ? "kept" : "removed");
|
||||
note(line);
|
||||
notef("setting %s %s", reaktor_setting("launchtest.key"), reaktor_setting("launchtest.gone") ? "kept" : "removed");
|
||||
}
|
||||
if (is("list") && g_frames == 4) {
|
||||
const reaktor_a11y_node *t = app->a11y.node[1 - app->a11y.front];
|
||||
int n = app->a11y.count[1 - app->a11y.front], i;
|
||||
const reaktor_a11y_node *t = last_node(app, REAKTOR_A11Y_LISTITEM, "row 1");
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].role == REAKTOR_A11Y_LISTITEM && t[i].name &&
|
||||
SDL_strcmp(t[i].name, "row 1") == 0)
|
||||
push_click(app, t[i].bounds.x + 10.0f, t[i].bounds.y + t[i].bounds.h * 0.5f);
|
||||
if (t) push_click(app, t->bounds.x + 10.0f, t->bounds.y + t->bounds.h * 0.5f);
|
||||
}
|
||||
if (is("list-keys") && (g_frames == 3 || g_frames == 4)) push_tap(app, SDLK_TAB);
|
||||
if (is("list-keys") && g_frames >= 6 && g_frames < 30 && g_frames % 2 == 0)
|
||||
push_tap(app, SDLK_DOWN);
|
||||
if (is("list-keys") && g_frames == 50) {
|
||||
SDL_snprintf(line, sizeof line, "chosen %d, %s", chosen,
|
||||
row_shown(app, chosen) ? "in view" : "out of view");
|
||||
note(line);
|
||||
notef("chosen %d, %s", chosen, row_shown(app, chosen) ? "in view" : "out of view");
|
||||
}
|
||||
if (split && (g_frames == 3 || g_frames == 5)) push_tap(app, SDLK_TAB);
|
||||
if (split && (g_frames == 8 || g_frames == 10))
|
||||
push_tap(app, is("split-vkeys") ? SDLK_DOWN : SDLK_RIGHT);
|
||||
if (split && g_frames == 12) push_tap(app, is("split-vkeys") ? SDLK_UP : SDLK_LEFT);
|
||||
if (split && g_frames == 30) {
|
||||
SDL_snprintf(line, sizeof line, "split %.2f", share);
|
||||
note(line);
|
||||
notef("split %.2f", share);
|
||||
}
|
||||
if (is("list") && chosen != said) {
|
||||
said = chosen;
|
||||
SDL_snprintf(line, sizeof line, "chosen %d", chosen);
|
||||
note(line);
|
||||
notef("chosen %d", chosen);
|
||||
}
|
||||
if (g_frames > 60) reaktor_quit(app, 0);
|
||||
REAKTOR_FREE(.w = (float)w, .h = (float)h) {
|
||||
@@ -786,21 +748,6 @@ focused_name(App *app)
|
||||
return "nothing";
|
||||
}
|
||||
|
||||
static int
|
||||
press_role(App *app, unsigned char role, const char *name)
|
||||
{
|
||||
const reaktor_a11y_node *t = app->a11y.node[1 - app->a11y.front];
|
||||
int n = app->a11y.count[1 - app->a11y.front], i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].role == role && t[i].name && SDL_strcmp(t[i].name, name) == 0) {
|
||||
push_click(app, t[i].bounds.x + t[i].bounds.w * 0.5f,
|
||||
t[i].bounds.y + t[i].bounds.h * 0.5f);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *
|
||||
expanded(App *app)
|
||||
{
|
||||
@@ -831,7 +778,6 @@ menu_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
static const reaktor_menu menus[] = { { "File", items, 4 }, { "View", view, 2 } };
|
||||
static const reaktor_menu_entry *pe;
|
||||
static int pm = -1;
|
||||
char line[96];
|
||||
|
||||
(void)ctx;
|
||||
if (g_frames >= 3 && g_frames <= 9 && g_frames % 2 &&
|
||||
@@ -846,10 +792,7 @@ menu_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
if (g_frames == 72) push_tap(app, SDLK_LEFT);
|
||||
if (g_frames == 20 || g_frames == 30 || g_frames == 45 || g_frames == 52 ||
|
||||
g_frames == 64 || g_frames == 90 || g_frames == 100 || g_frames == 108) {
|
||||
SDL_snprintf(line, sizeof line, "open %s, focus on %s, picked %s in %d, wrap %s",
|
||||
expanded(app), focused_name(app), pe ? pe->label : "nothing", pm,
|
||||
wrap ? "on" : "off");
|
||||
note(line);
|
||||
notef("open %s, focus on %s, picked %s in %d, wrap %s", expanded(app), focused_name(app), pe ? pe->label : "nothing", pm, wrap ? "on" : "off");
|
||||
}
|
||||
if (g_frames == 94 || g_frames == 102) press_role(app, REAKTOR_A11Y_MENU, "File");
|
||||
if (g_frames > 112) reaktor_quit(app, 0);
|
||||
@@ -875,7 +818,6 @@ tree_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
{
|
||||
static unsigned char open[6];
|
||||
static int sel = -1;
|
||||
char line[96];
|
||||
static const SDL_Keycode keys[] = { SDLK_TAB, SDLK_RIGHT, SDLK_RIGHT, SDLK_RIGHT,
|
||||
SDLK_DOWN, SDLK_LEFT, SDLK_LEFT };
|
||||
int k = (g_frames - 4) / 6;
|
||||
@@ -884,23 +826,16 @@ tree_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
if (g_frames >= 4 && (g_frames - 4) % 6 == 0 && k < (int)SDL_arraysize(keys))
|
||||
push_tap(app, keys[k]);
|
||||
if (g_frames >= 4 && (g_frames - 4) % 6 == 5 && k < (int)SDL_arraysize(keys)) {
|
||||
SDL_snprintf(line, sizeof line, "focus %s, selected %d, open %d%d%d%d%d%d",
|
||||
focused_name(app), sel, open[0], open[1], open[2], open[3],
|
||||
open[4], open[5]);
|
||||
note(line);
|
||||
notef("focus %s, selected %d, open %d%d%d%d%d%d", focused_name(app), sel, open[0], open[1], open[2], open[3], open[4], open[5]);
|
||||
}
|
||||
if (g_frames == 60) press_role(app, REAKTOR_A11Y_TREEITEM, "B");
|
||||
if (g_frames == 66) {
|
||||
const reaktor_a11y_node *t = app->a11y.node[1 - app->a11y.front];
|
||||
int n = app->a11y.count[1 - app->a11y.front], i;
|
||||
const reaktor_a11y_node *t = last_node(app, REAKTOR_A11Y_TREEITEM, "B");
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (t[i].role == REAKTOR_A11Y_TREEITEM && SDL_strcmp(t[i].name, "B") == 0)
|
||||
push_click(app, t[i].bounds.x + 15.0f, t[i].bounds.y + t[i].bounds.h * 0.5f);
|
||||
if (t) push_click(app, t->bounds.x + 15.0f, t->bounds.y + t->bounds.h * 0.5f);
|
||||
}
|
||||
if (g_frames == 72) {
|
||||
SDL_snprintf(line, sizeof line, "clicked: selected %d, B open %d", sel, open[4]);
|
||||
note(line);
|
||||
notef("clicked: selected %d, B open %d", sel, open[4]);
|
||||
}
|
||||
if (g_frames > 76) reaktor_quit(app, 0);
|
||||
REAKTOR_FREE(.w = (float)w, .h = (float)h) {
|
||||
@@ -919,7 +854,6 @@ find_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
static char *text, run[601];
|
||||
static int len, cap;
|
||||
struct nk_window *pw = nk_window_find(ctx, "page");
|
||||
char line[96];
|
||||
|
||||
if (g_frames == 3) {
|
||||
SDL_memset(run, 'x', 600);
|
||||
@@ -928,14 +862,11 @@ find_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
}
|
||||
if (g_frames == 8) push_text(app, run);
|
||||
if (g_frames == 70) {
|
||||
SDL_snprintf(line, sizeof line, "len %d, room %s", len, cap > len ? "kept" : "short");
|
||||
note(line);
|
||||
notef("len %d, room %s", len, cap > len ? "kept" : "short");
|
||||
reaktor_field_select(app, text, 10, 20);
|
||||
}
|
||||
if (g_frames == 84 && pw) {
|
||||
SDL_snprintf(line, sizeof line, "active %d, selected %d to %d", pw->edit.active,
|
||||
pw->edit.sel_start, pw->edit.sel_end);
|
||||
note(line);
|
||||
notef("active %d, selected %d to %d", pw->edit.active, pw->edit.sel_start, pw->edit.sel_end);
|
||||
}
|
||||
if (g_frames > 88) reaktor_quit(app, 0);
|
||||
REAKTOR_FREE(.w = (float)w, .h = (float)h) {
|
||||
@@ -956,14 +887,12 @@ spin_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
SDLK_LEFT, SDLK_TAB, SDLK_LEFT };
|
||||
static int one, two;
|
||||
int k = (g_frames - 4) / 6;
|
||||
char line[64];
|
||||
|
||||
(void)ctx;
|
||||
if (g_frames >= 4 && (g_frames - 4) % 6 == 0 && k < (int)SDL_arraysize(keys))
|
||||
push_tap(app, keys[k]);
|
||||
if (g_frames == 50) {
|
||||
SDL_snprintf(line, sizeof line, "stops at %d, wraps to %d", one, two);
|
||||
note(line);
|
||||
notef("stops at %d, wraps to %d", one, two);
|
||||
}
|
||||
if (g_frames > 54) reaktor_quit(app, 0);
|
||||
REAKTOR_FREE(.w = (float)w, .h = (float)h) {
|
||||
@@ -987,28 +916,23 @@ date_page(App *app, struct nk_context *ctx, int w, int h)
|
||||
SDLK_LEFT, SDLK_DOWN, SDLK_RETURN, SDLK_TAB,
|
||||
SDLK_RETURN, SDLK_UP, SDLK_ESCAPE };
|
||||
int k = (g_frames - 4) / 8;
|
||||
char line[96];
|
||||
|
||||
(void)ctx;
|
||||
if (g_frames >= 4 && (g_frames - 4) % 8 == 0 && k < (int)SDL_arraysize(keys))
|
||||
push_tap(app, keys[k]);
|
||||
if (g_frames == 16) note(d ? "set too early" : "open, not set");
|
||||
if (g_frames == 60) {
|
||||
SDL_snprintf(line, sizeof line, "hour %d, focus on %s", hh, focused_name(app));
|
||||
note(line);
|
||||
notef("hour %d, focus on %s", hh, focused_name(app));
|
||||
}
|
||||
if (g_frames == 100) {
|
||||
SDL_snprintf(line, sizeof line, "after escape: hour %d, focus on %s", hh,
|
||||
focused_name(app));
|
||||
note(line);
|
||||
notef("after escape: hour %d, focus on %s", hh, focused_name(app));
|
||||
}
|
||||
if (g_frames > 104) reaktor_quit(app, 0);
|
||||
REAKTOR_FREE(.w = (float)w, .h = (float)h) {
|
||||
REAKTOR_ROW(.w = (float)w, .h = 30.0f) {
|
||||
if (reaktor_date_pick(&(reaktor_date_spec){ .name = "Date", .year = &y,
|
||||
.month = &m, .day = &d })) {
|
||||
SDL_snprintf(line, sizeof line, "set %04d-%02d-%02d", y, m, d);
|
||||
note(line);
|
||||
notef("set %04d-%02d-%02d", y, m, d);
|
||||
}
|
||||
reaktor_time_pick(&(reaktor_time_spec){ .name = "Time", .hour = &hh,
|
||||
.minute = &mm });
|
||||
@@ -1044,7 +968,6 @@ static void
|
||||
undo_page(App *app)
|
||||
{
|
||||
static int one = 1;
|
||||
char line[128];
|
||||
|
||||
if (g_frames == 2) {
|
||||
reaktor_undo_step s = { "Add", undo_minus, undo_plus, NULL, &one, 0 };
|
||||
@@ -1063,11 +986,7 @@ undo_page(App *app)
|
||||
if (g_frames == 6 || g_frames == 12) push_chord(app, SDLK_Z, SDL_KMOD_CTRL);
|
||||
if (g_frames == 18) push_chord(app, SDLK_Z, SDL_KMOD_CTRL | SDL_KMOD_SHIFT);
|
||||
if (g_frames == 4 || g_frames == 16 || g_frames == 24) {
|
||||
SDL_snprintf(line, sizeof line, "value %d, undo %s, redo %s, %s", g_undo_v,
|
||||
reaktor_undo_label(app) ? reaktor_undo_label(app) : "-",
|
||||
reaktor_redo_label(app) ? reaktor_redo_label(app) : "-",
|
||||
reaktor_undo_dirty(app) ? "changed" : "saved");
|
||||
note(line);
|
||||
notef("value %d, undo %s, redo %s, %s", g_undo_v, reaktor_undo_label(app) ? reaktor_undo_label(app) : "-", reaktor_redo_label(app) ? reaktor_redo_label(app) : "-", reaktor_undo_dirty(app) ? "changed" : "saved");
|
||||
}
|
||||
if (g_frames > 28) reaktor_quit(app, 0);
|
||||
app->dirty = 1;
|
||||
@@ -1130,7 +1049,7 @@ confirm_page(App *app)
|
||||
SDL_PushEvent(&e);
|
||||
}
|
||||
if (g_frames == 10)
|
||||
note(press_named(app, is("confirm") ? "Quit" : "Cancel") ? "asked"
|
||||
note(press_role(app, REAKTOR_A11Y_BUTTON, is("confirm") ? "Quit" : "Cancel") ? "asked"
|
||||
: "not asked");
|
||||
if (g_frames == 25) {
|
||||
note("still running");
|
||||
@@ -1146,7 +1065,6 @@ leak_page(App *app)
|
||||
static int cycle, id;
|
||||
static size_t rss0, priv0;
|
||||
size_t rss, priv;
|
||||
char line[80];
|
||||
|
||||
if (id) {
|
||||
reaktor_window_close(app, id);
|
||||
@@ -1156,9 +1074,7 @@ leak_page(App *app)
|
||||
if (++cycle == 10) reaktor_process_memory(&rss0, &priv0);
|
||||
} else {
|
||||
reaktor_process_memory(&rss, &priv);
|
||||
SDL_snprintf(line, sizeof line, "grew %d KB private over 200 windows",
|
||||
(int)(((long long)priv - (long long)priv0) / 1024));
|
||||
note(line);
|
||||
notef("grew %d KB private over 200 windows", (int)(((long long)priv - (long long)priv0) / 1024));
|
||||
reaktor_quit(app, 0);
|
||||
return;
|
||||
}
|
||||
@@ -1169,8 +1085,6 @@ leak_page(App *app)
|
||||
static void
|
||||
page(App *app, struct nk_context *ctx, int w, int h)
|
||||
{
|
||||
char line[80];
|
||||
|
||||
g_frames++;
|
||||
if (is("win-leak")) {
|
||||
leak_page(app);
|
||||
@@ -1217,9 +1131,7 @@ page(App *app, struct nk_context *ctx, int w, int h)
|
||||
return;
|
||||
}
|
||||
if (ctx->input.keyboard.text_len > 0) {
|
||||
SDL_snprintf(line, sizeof line, "text %.*s",
|
||||
ctx->input.keyboard.text_len, ctx->input.keyboard.text);
|
||||
note(line);
|
||||
notef("text %.*s", ctx->input.keyboard.text_len, ctx->input.keyboard.text);
|
||||
}
|
||||
if (is("title")) reaktor_set_title(app, "Renamed");
|
||||
REAKTOR_FREE(.w = (float)w, .h = (float)h) {
|
||||
@@ -1248,11 +1160,8 @@ request_twice(void *app)
|
||||
static int SDLCALL
|
||||
count_frames(void *app)
|
||||
{
|
||||
char line[32];
|
||||
|
||||
SDL_Delay(1500);
|
||||
SDL_snprintf(line, sizeof line, "frames %d", g_frames);
|
||||
note(line);
|
||||
notef("frames %d", g_frames);
|
||||
reaktor_quit((App *)app, 0);
|
||||
return 0;
|
||||
}
|
||||
@@ -1352,16 +1261,12 @@ key(App *app, const SDL_Event *e)
|
||||
static void
|
||||
picked(App *app, const char *const *paths, int count, void *user)
|
||||
{
|
||||
char line[600];
|
||||
int i;
|
||||
|
||||
(void)user;
|
||||
SDL_snprintf(line, sizeof line, "file in %s: %s",
|
||||
app->secondary ? "window" : "main", count ? paths[0] : "(none)");
|
||||
note(line);
|
||||
notef("file in %s: %s", app->secondary ? "window" : "main", count ? paths[0] : "(none)");
|
||||
for (i = 1; i < count; i++) {
|
||||
SDL_snprintf(line, sizeof line, "and %s", paths[i]);
|
||||
note(line);
|
||||
notef("and %s", paths[i]);
|
||||
}
|
||||
if (SDL_strncmp(g_mode, "dialog-", 7) == 0) reaktor_quit(app, 0);
|
||||
}
|
||||
@@ -1385,21 +1290,14 @@ dialog_page(App *app)
|
||||
static void
|
||||
file_opened(App *app, const char *path)
|
||||
{
|
||||
char line[96];
|
||||
|
||||
SDL_snprintf(line, sizeof line, "file in %s: %s",
|
||||
app->secondary ? "window" : "main", path ? path : "(none)");
|
||||
note(line);
|
||||
notef("file in %s: %s", app->secondary ? "window" : "main", path ? path : "(none)");
|
||||
}
|
||||
|
||||
static int
|
||||
closing(App *app, reaktor_quit_reason why)
|
||||
{
|
||||
char line[64];
|
||||
|
||||
(void)app;
|
||||
SDL_snprintf(line, sizeof line, "closing %d", (int)why);
|
||||
note(line);
|
||||
notef("closing %d", (int)why);
|
||||
return (is("veto") || is("request")) && ++g_closings == 1;
|
||||
}
|
||||
|
||||
@@ -1436,10 +1334,8 @@ main(int argc, char **argv)
|
||||
int rc = launchApp(argc, argv, &l);
|
||||
|
||||
if (is("twice")) {
|
||||
char line[32];
|
||||
|
||||
SDL_snprintf(line, sizeof line, "again %d", launchApp(argc, argv, &l));
|
||||
note(line);
|
||||
notef("again %d", launchApp(argc, argv, &l));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
+3
-3
@@ -24,7 +24,7 @@ frame(reaktor_layout *l, float gap)
|
||||
|
||||
root.dir = REAKTOR_LAY_ROW;
|
||||
root.gap = gap;
|
||||
root.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y;
|
||||
root.flags = REAKTOR_LAY_FILL;
|
||||
|
||||
fixed.w = 100.0f;
|
||||
fixed.h = 30.0f;
|
||||
@@ -87,7 +87,7 @@ test_centring(reaktor_layout *l)
|
||||
puts("");
|
||||
puts("centering is asked for, never assumed");
|
||||
row.dir = REAKTOR_LAY_ROW;
|
||||
row.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y;
|
||||
row.flags = REAKTOR_LAY_FILL;
|
||||
top.w = mid.w = 40.0f;
|
||||
top.h = mid.h = 20.0f;
|
||||
mid.flags = REAKTOR_LAY_CENTER_Y;
|
||||
@@ -191,7 +191,7 @@ test_nesting(reaktor_layout *l)
|
||||
puts("");
|
||||
puts("a box inside a box");
|
||||
col.dir = REAKTOR_LAY_COLUMN;
|
||||
col.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y;
|
||||
col.flags = REAKTOR_LAY_FILL;
|
||||
row.dir = REAKTOR_LAY_ROW;
|
||||
row.h = 40.0f;
|
||||
row.flags = REAKTOR_LAY_FILL_X;
|
||||
|
||||
+1
-4
@@ -71,10 +71,7 @@ reaktor_locale_system_code(void)
|
||||
static void
|
||||
check_str(const char *what, const char *got, const char *want)
|
||||
{
|
||||
if (got && want && !strcmp(got, want)) return;
|
||||
printf("FAIL %s: got \"%s\", want \"%s\"\n", what, got ? got : "(null)",
|
||||
want ? want : "(null)");
|
||||
failures++;
|
||||
test_str(what, got, want);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define REAKTOR_TEST_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int failures;
|
||||
|
||||
@@ -23,6 +24,18 @@ test_eq(const char *what, long got, long want)
|
||||
printf(" %-56s got %ld, wanted %ld FAILED\n", what, got, want);
|
||||
}
|
||||
|
||||
static void
|
||||
test_str(const char *what, const char *got, const char *want)
|
||||
{
|
||||
if (got && want && strcmp(got, want) == 0) {
|
||||
printf(" %-56s \"%s\"\n", what, got);
|
||||
return;
|
||||
}
|
||||
failures++;
|
||||
printf(" %-56s got \"%s\", wanted \"%s\" FAILED\n", what, got ? got : "(null)",
|
||||
want ? want : "(null)");
|
||||
}
|
||||
|
||||
static int
|
||||
test_done(const char *name)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
onlaytest
|
||||
keytest
|
||||
a11ytest
|
||||
animtest
|
||||
localetest
|
||||
laytest
|
||||
texttest
|
||||
csstest
|
||||
basetest
|
||||
imagetest
|
||||
Reference in New Issue
Block a user