Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c42bdfe540 | ||
|
|
61534c087c | ||
|
|
b945683c42 | ||
|
|
9a6e59120b | ||
|
|
0d12e4d0d9 | ||
|
|
22489b65bd | ||
|
|
96e5641971 | ||
|
|
55dca9f496 | ||
|
|
e02539ea7b | ||
|
|
808c18fb58 | ||
|
|
8c2f9cbc4f | ||
|
|
1bb65db393 | ||
|
|
9fcfe47728 | ||
|
|
b741f81dbd | ||
|
|
5b15189d39 | ||
|
|
ee8d1da49d | ||
|
|
95e5122ed0 | ||
|
|
6ff47bce3b | ||
|
|
42296886c6 | ||
|
|
93c636bc1c | ||
|
|
394ffacbaa | ||
|
|
56e349bd51 | ||
|
|
73557404e2 | ||
|
|
3a5b9cc9b7 | ||
|
|
37f80df4b9 | ||
|
|
3b41f696c1 | ||
|
|
839873fb7f | ||
|
|
311e1fdd89 | ||
|
|
84e45229ea | ||
|
|
b748fd9984 | ||
|
|
965ee181b5 | ||
|
|
1f67384eba | ||
|
|
4f9f322a33 | ||
|
|
6d009d1ad5 | ||
|
|
468c6e2d1c | ||
|
|
e6c0b85601 |
@@ -96,7 +96,7 @@ jobs:
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
fail=0
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest; do
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest csstest; do
|
||||
echo "== $t"
|
||||
if ./build/$t </dev/null; then :; else echo "$t: exit status $?"; fail=1; fi
|
||||
done
|
||||
@@ -180,6 +180,31 @@ jobs:
|
||||
tar -C dist -czf "dist/$name.tar.gz" "$name"
|
||||
rm -rf "dist/$name"
|
||||
|
||||
- name: Check and pack libreaktor
|
||||
id: libcheck
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
PATH=/usr/pkg/sbin:/usr/pkg/bin:/usr/local/sbin:/usr/local/bin:$PATH
|
||||
export PATH
|
||||
version='${{ inputs.version || 'dev' }}'
|
||||
name="libreaktor-${version#v}-${{ matrix.os }}-${{ matrix.arch }}"
|
||||
cmake --build build --target libreaktor </dev/null
|
||||
cmake --install build --prefix "dist/$name" --component libreaktor </dev/null
|
||||
cmake -S examples/consumer -B build-consumer -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||
"-DCMAKE_PREFIX_PATH=$PWD/dist/$name" </dev/null
|
||||
cmake --build build-consumer </dev/null
|
||||
mkdir -p check
|
||||
for from in "lib-built build/simple" "lib-linked build-consumer/simple"; do
|
||||
set -- $from
|
||||
dbus-run-session -- "$2" --theme light --video dummy \
|
||||
--shot "check/$1.bmp" --a11y-dump "check/$1.txt" </dev/null
|
||||
done
|
||||
for e in bmp txt; do
|
||||
cmp "check/lib-built.$e" "check/lib-linked.$e"
|
||||
done
|
||||
tar -C dist -czf "dist/$name.tar.gz" "$name"
|
||||
rm -rf "dist/$name" build-consumer
|
||||
|
||||
- name: Collect the shots
|
||||
if: ${{ always() && steps.vm.outcome == 'success' }}
|
||||
shell: cpa.sh {0} --sync-files vm-to-runner
|
||||
@@ -195,7 +220,16 @@ jobs:
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-${{ matrix.os }}-${{ matrix.arch }}
|
||||
path: dist/*.tar.gz
|
||||
path: dist/reaktor-*.tar.gz
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
- name: Upload libreaktor
|
||||
if: ${{ !cancelled() && steps.libcheck.outcome == 'success' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-libreaktor-${{ matrix.os }}-${{ matrix.arch }}
|
||||
path: dist/libreaktor-*.tar.gz
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
run: |
|
||||
docker exec -i debian sh -u <<'EOF'
|
||||
fail=0
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest; do
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest csstest; do
|
||||
echo "== $t"
|
||||
if ./build/$t </dev/null; then :; else echo "$t: exit status $?"; fail=1; fi
|
||||
done
|
||||
@@ -163,7 +163,57 @@ jobs:
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-linux-${{ matrix.arch }}
|
||||
path: dist/*.tar.gz
|
||||
path: dist/reaktor-*.tar.gz
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
- name: Check and pack libreaktor
|
||||
id: libcheck
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
version='${{ inputs.version || 'dev' }}'
|
||||
name="libreaktor-${version#v}-linux-${{ matrix.arch }}"
|
||||
docker exec -i -e name="$name" debian sh -eu <<'EOF'
|
||||
cmake --build build --target libreaktor </dev/null
|
||||
cmake --install build --prefix "dist/$name" --component libreaktor </dev/null
|
||||
cmake -S examples/consumer -B build-consumer -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||
"-DCMAKE_PREFIX_PATH=$PWD/dist/$name" </dev/null
|
||||
cmake --build build-consumer </dev/null
|
||||
mkdir -p check
|
||||
for from in "lib-built build/simple" "lib-linked build-consumer/simple"; do
|
||||
set -- $from
|
||||
timeout 600 "$2" --theme light --video dummy \
|
||||
--shot "check/$1.bmp" --a11y-dump "check/$1.txt" </dev/null
|
||||
done
|
||||
for e in bmp txt; do
|
||||
cmp "check/lib-built.$e" "check/lib-linked.$e"
|
||||
done
|
||||
tar -C dist -czf "dist/$name.tar.gz" "$name"
|
||||
EOF
|
||||
|
||||
- name: Check an app that embeds Reaktor
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' && matrix.arch == 'x86-64' }}
|
||||
run: |
|
||||
docker exec -i debian sh -eu <<'EOF'
|
||||
cmake -S examples/embedded -B build-embedded -G Ninja -DCMAKE_BUILD_TYPE=Release </dev/null
|
||||
cmake --build build-embedded --target simple </dev/null
|
||||
mkdir -p check
|
||||
for from in "tree build/simple" "embedded build-embedded/simple"; do
|
||||
set -- $from
|
||||
timeout 600 dbus-run-session -- "$2" --theme light --video dummy \
|
||||
--shot "check/$1.bmp" --a11y-dump "check/$1.txt" </dev/null
|
||||
done
|
||||
for e in bmp txt; do
|
||||
cmp "check/tree.$e" "check/embedded.$e"
|
||||
done
|
||||
EOF
|
||||
|
||||
- name: Upload libreaktor
|
||||
if: ${{ !cancelled() && steps.libcheck.outcome == 'success' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-libreaktor-linux-${{ matrix.arch }}
|
||||
path: dist/libreaktor-*.tar.gz
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
fail=0
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest; do
|
||||
for t in onlaytest keytest a11ytest animtest localetest laytest texttest csstest; do
|
||||
echo "== $t"
|
||||
if ./build/$t </dev/null; then :; else echo "$t: exit status $?"; fail=1; fi
|
||||
done
|
||||
@@ -126,7 +126,53 @@ jobs:
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-macos-${{ matrix.arch }}
|
||||
path: dist/*.zip
|
||||
path: dist/reaktor-*.zip
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
- name: Check and zip libreaktor
|
||||
id: libcheck
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
version='${{ inputs.version || 'dev' }}'
|
||||
name="libreaktor-${version#v}-macos-${{ matrix.arch }}"
|
||||
cmake --build build --target libreaktor </dev/null
|
||||
cmake --install build --prefix "dist/$name" --component libreaktor </dev/null
|
||||
cmake -S examples/consumer -B build-consumer -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||
"-DCMAKE_PREFIX_PATH=$PWD/dist/$name" </dev/null
|
||||
cmake --build build-consumer </dev/null
|
||||
mkdir -p check
|
||||
for from in "lib-built build/simple" "lib-linked build-consumer/simple"; do
|
||||
set -- $from
|
||||
"$2" --theme light --video dummy \
|
||||
--shot "check/$1.bmp" --a11y-dump "check/$1.txt" </dev/null
|
||||
done
|
||||
for e in bmp txt; do
|
||||
cmp "check/lib-built.$e" "check/lib-linked.$e"
|
||||
done
|
||||
ditto -c -k --keepParent "dist/$name" "dist/$name.zip"
|
||||
|
||||
- name: Check an app that embeds Reaktor
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
cmake -S examples/embedded -B build-embedded -G Ninja -DCMAKE_BUILD_TYPE=Release </dev/null
|
||||
cmake --build build-embedded --target simple </dev/null
|
||||
mkdir -p check
|
||||
for from in "tree build/simple" "embedded build-embedded/simple"; do
|
||||
set -- $from
|
||||
"$2" --theme light --video dummy \
|
||||
--shot "check/$1.bmp" --a11y-dump "check/$1.txt" </dev/null
|
||||
done
|
||||
for e in bmp txt; do
|
||||
cmp "check/tree.$e" "check/embedded.$e"
|
||||
done
|
||||
|
||||
- name: Upload libreaktor
|
||||
if: ${{ !cancelled() && steps.libcheck.outcome == 'success' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-libreaktor-macos-${{ matrix.arch }}
|
||||
path: dist/libreaktor-*.zip
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
|
||||
@@ -44,6 +44,19 @@ jobs:
|
||||
persist-credentials: false
|
||||
path: src
|
||||
|
||||
- name: Version
|
||||
run: |
|
||||
v=${GITHUB_REF_NAME#v}
|
||||
v=${v%%-*}
|
||||
if ! grep -qF "project(reaktor VERSION $v " src/CMakeLists.txt; then
|
||||
echo "$GITHUB_REF_NAME, but CMakeLists.txt is not at $v"
|
||||
exit 1
|
||||
fi
|
||||
if ! grep -qF "find_package(reaktor ${v%.*} REQUIRED)" src/docs/DOCUMENTATION.md; then
|
||||
echo "$GITHUB_REF_NAME, but docs/DOCUMENTATION.md does not ask find_package for ${v%.*}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Archive
|
||||
run: |
|
||||
name="reaktor-${GITHUB_REF_NAME#v}-source"
|
||||
@@ -104,9 +117,31 @@ jobs:
|
||||
the \`.wasm\`) and open \`showcase.html\`; the same showcase runs at
|
||||
https://alpaq92.github.io/Reaktor/.
|
||||
|
||||
GitHub's own source archives below leave the submodules out; the
|
||||
\`-source.tar.gz\` above has them.
|
||||
### libreaktor
|
||||
|
||||
The library itself, for building your own applications: the same
|
||||
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, libcss, 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.
|
||||
|
||||
\`\`\`cmake
|
||||
find_package(reaktor ${v%.*} REQUIRED) # with CMAKE_PREFIX_PATH at the unpacked folder
|
||||
add_executable(app WIN32 main.c)
|
||||
target_link_libraries(app PRIVATE reaktor::reaktor)
|
||||
\`\`\`
|
||||
|
||||
or \`cc main.c \$(pkg-config --cflags --libs reaktor)\` with
|
||||
\`PKG_CONFIG_PATH\` at its \`lib/pkgconfig\`.
|
||||
|
||||
\`SHA256SUMS\` lists every download's checksum. GitHub's own source
|
||||
archives below leave the submodules out; the \`-source.tar.gz\` above has
|
||||
them.
|
||||
EOF
|
||||
(cd dist && sha256sum -- * >SHA256SUMS)
|
||||
gh release create "$GITHUB_REF_NAME" dist/* --repo "$GITHUB_REPOSITORY" \
|
||||
--title "Reaktor $GITHUB_REF_NAME" --notes-file notes.md --generate-notes \
|
||||
--verify-tag
|
||||
|
||||
@@ -64,6 +64,27 @@ jobs:
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-web
|
||||
path: dist/*.zip
|
||||
path: dist/reaktor-*.zip
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
- name: Check and pack libreaktor
|
||||
run: |
|
||||
version='${{ inputs.version || 'dev' }}'
|
||||
name="libreaktor-${version#v}-wasm"
|
||||
cmake --build build-wasm --target libreaktor
|
||||
cmake --install build-wasm --prefix "dist/$name" --component libreaktor
|
||||
cmake -S examples/consumer -B build-consumer -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||
"-DCMAKE_TOOLCHAIN_FILE=$HOME/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" \
|
||||
"-Dreaktor_DIR=$PWD/dist/$name/lib/cmake/reaktor"
|
||||
cmake --build build-consumer
|
||||
test -s build-consumer/simple.wasm
|
||||
tar -C dist -czf "dist/$name.tar.gz" "$name"
|
||||
|
||||
- name: Upload libreaktor
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-libreaktor-wasm
|
||||
path: dist/libreaktor-*.tar.gz
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
$fail = 0
|
||||
foreach ($t in 'onlaytest', 'keytest', 'a11ytest', 'animtest', 'localetest', 'laytest', 'texttest') {
|
||||
foreach ($t in 'onlaytest', 'keytest', 'a11ytest', 'animtest', 'localetest', 'laytest', 'texttest', 'csstest') {
|
||||
Write-Host "== $t"
|
||||
& "./${{ matrix.out }}/$t.exe"
|
||||
if ($LASTEXITCODE -ne 0) { Write-Host "${t}: exit status $LASTEXITCODE"; $fail = 1 }
|
||||
@@ -122,7 +122,48 @@ jobs:
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-windows-${{ matrix.arch }}
|
||||
path: dist/*.zip
|
||||
path: dist/reaktor-*.zip
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
- name: Build libreaktor
|
||||
id: lib
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: ./build.ps1 -Arch ${{ matrix.arch }} -Out build-lib libreaktor
|
||||
|
||||
- name: Check and zip libreaktor
|
||||
id: libcheck
|
||||
if: ${{ !cancelled() && steps.lib.outcome == 'success' }}
|
||||
run: |
|
||||
$version = '${{ inputs.version || 'dev' }}' -replace '^v', ''
|
||||
$name = "libreaktor-$version-windows-${{ matrix.arch }}"
|
||||
cmake --install build-lib --prefix "dist/$name" --component libreaktor
|
||||
if ($LASTEXITCODE -ne 0) { throw "install failed" }
|
||||
./build.ps1 -Arch ${{ matrix.arch }} -Source examples/consumer -Out build-consumer `
|
||||
"-DCMAKE_PREFIX_PATH=$PWD/dist/$name"
|
||||
New-Item -ItemType Directory -Force check | Out-Null
|
||||
foreach ($from in @(@('lib-built', "${{ matrix.out }}/simple.exe"),
|
||||
@('lib-linked', 'build-consumer/simple.exe'))) {
|
||||
$p = Start-Process -FilePath $from[1] -PassThru -ArgumentList @(
|
||||
'--theme', 'light', '--video', 'dummy',
|
||||
'--shot', "check/$($from[0]).bmp", '--a11y-dump', "check/$($from[0]).txt")
|
||||
$null = $p.Handle
|
||||
if (-not $p.WaitForExit(600000)) { $p.Kill(); throw "$($from[0]): timed out" }
|
||||
if ($p.ExitCode -ne 0) { throw "$($from[0]): exit status $($p.ExitCode)" }
|
||||
}
|
||||
foreach ($e in 'bmp', 'txt') {
|
||||
if ((Get-FileHash "check/lib-built.$e").Hash -ne (Get-FileHash "check/lib-linked.$e").Hash) {
|
||||
throw "simple linked against libreaktor draws differently ($e)"
|
||||
}
|
||||
}
|
||||
Compress-Archive -Path "dist/$name" -DestinationPath "dist/$name.zip"
|
||||
|
||||
- name: Upload libreaktor
|
||||
if: ${{ !cancelled() && steps.libcheck.outcome == 'success' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-libreaktor-windows-${{ matrix.arch }}
|
||||
path: dist/libreaktor-*.zip
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ build-wasm/
|
||||
build-x64/
|
||||
build-x86/
|
||||
build-arm64/
|
||||
build-lib/
|
||||
build-consumer/
|
||||
build-embedded/
|
||||
.claude/settings.local.json
|
||||
.dart_tool/
|
||||
.gradle/
|
||||
|
||||
@@ -28,3 +28,6 @@
|
||||
[submodule "external/kb"]
|
||||
path = external/kb
|
||||
url = https://github.com/JimmyLefevre/kb.git
|
||||
[submodule "external/nukanim"]
|
||||
path = external/nukanim
|
||||
url = https://github.com/Alpaq92/NukAnim.git
|
||||
|
||||
@@ -57,8 +57,9 @@ regression oracle for every layout or style change.
|
||||
- **A one-pixel stroke is two pixels here.** `nk_stroke_rect` casts its rect to
|
||||
`short`, so a half-pixel inset never reaches the draw list, and with line
|
||||
anti-aliasing on a stroke of thickness one is always two half-alpha rows.
|
||||
A border is `reaktor_edge_round`: fills for its runs, a ring mask for its
|
||||
corners, inside the box.
|
||||
A border is `reaktor_edge_round`, inside the box: a ring mask for its
|
||||
corners, and its runs cut from the mask's middle texels, which hold a
|
||||
straight band so a run is sharp and as thick as its corners at any scale.
|
||||
- **A rounded fill is jagged unless it is a mask.** Fill anti-aliasing is off
|
||||
on every renderer, so a fill with corners goes through `reaktor_fill_round`,
|
||||
and `reaktor_render` swaps each one Nuklear drew itself for masks, relinking
|
||||
@@ -113,6 +114,10 @@ regression oracle for every layout or style change.
|
||||
toast's close cross) are compiled in byte for byte, beside the Aileron
|
||||
fonts, the mark and reaktor.css. Nothing else from a submodule is — not the
|
||||
rest of Ionicons, not simple.css.
|
||||
- Applications see only `include/reaktor/`. The samples include
|
||||
`reaktor/reaktor.h` and `reaktor/main.h`, nothing from `src/` or `core/`, and
|
||||
`App` is opaque to them; what a sample needs becomes a public call there.
|
||||
MSVC builds apps with implicit declarations as errors, which catches a miss.
|
||||
- American English, in code and prose.
|
||||
- No environment variables. Anything worth overriding is a command-line flag
|
||||
the runtime strips from `argv`.
|
||||
|
||||
+304
-21
@@ -1,10 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(reaktor C CXX)
|
||||
project(reaktor VERSION 0.4.0 LANGUAGES C CXX)
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(_reaktor_top ON)
|
||||
else()
|
||||
set(_reaktor_top OFF)
|
||||
endif()
|
||||
option(REAKTOR_SAMPLES "Build the samples" ${_reaktor_top})
|
||||
option(REAKTOR_TESTS "Build the tests" ${_reaktor_top})
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
if(_reaktor_top AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
|
||||
endif()
|
||||
|
||||
@@ -79,7 +87,13 @@ foreach(_in "${LC}/yutil/include/yutil/config.h.in"
|
||||
lcui_expand("${_in}" _part)
|
||||
string(APPEND LCUI_MERGED "\n${_part}")
|
||||
endforeach()
|
||||
file(WRITE "${LCUI_CFG}/config.h" "${LCUI_MERGED}")
|
||||
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)
|
||||
@@ -116,7 +130,7 @@ add_library(onlay STATIC ${TP}/onlay/onlay.c)
|
||||
target_include_directories(onlay PUBLIC ${TP}/onlay)
|
||||
target_compile_definitions(onlay PUBLIC LAY_FLOAT=1)
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
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
|
||||
@@ -167,12 +181,15 @@ if(NOT _old STREQUAL _gen)
|
||||
endif()
|
||||
message(STATUS "assets: ${_n} compiled in")
|
||||
|
||||
add_library(reaktor_headers INTERFACE)
|
||||
target_include_directories(reaktor_headers INTERFACE include "${TP}/nuklear" "${TP}/nukanim")
|
||||
|
||||
add_library(reaktor_core STATIC
|
||||
core/base/util.c
|
||||
core/render/appicon.c
|
||||
"${_builtins}")
|
||||
target_include_directories(reaktor_core PUBLIC core/base core/render)
|
||||
target_link_libraries(reaktor_core PUBLIC plutosvg)
|
||||
target_link_libraries(reaktor_core PUBLIC plutosvg reaktor_headers)
|
||||
|
||||
set(APP_ICON assets/icons/reaktor-icon.ico)
|
||||
set(APP_RESOURCES "")
|
||||
@@ -182,42 +199,52 @@ target_link_libraries(mkicon PRIVATE reaktor_core)
|
||||
set_target_properties(mkicon PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
add_executable(keytest tools/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(NOT EMSCRIPTEN)
|
||||
if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
add_executable(a11ytest tools/a11ytest.c core/a11y/a11y.c)
|
||||
target_link_libraries(a11ytest PRIVATE reaktor_headers)
|
||||
target_include_directories(a11ytest PRIVATE core/a11y core/render)
|
||||
set_target_properties(a11ytest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
add_executable(animtest tools/animtest.c core/anim/anim.c)
|
||||
target_include_directories(animtest PRIVATE core/anim core/a11y core/render
|
||||
platform)
|
||||
target_link_libraries(animtest PRIVATE SDL3::SDL3)
|
||||
if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
add_executable(animtest tools/animtest.c core/anim/anim.c core/render/nk_impl.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 tools/localetest.c
|
||||
core/locale/locale.c core/locale/plural.c
|
||||
core/locale/format.c)
|
||||
target_link_libraries(localetest PRIVATE reaktor_headers)
|
||||
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 tools/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 tools/csstest.c core/css/cssflat.c)
|
||||
target_include_directories(csstest PRIVATE core/css core/base)
|
||||
target_compile_definitions(csstest PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
set_target_properties(csstest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT EMSCRIPTEN)
|
||||
@@ -229,8 +256,14 @@ if(WIN32)
|
||||
file(MAKE_DIRECTORY "${GEN}")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${APP_ICON}"
|
||||
"${GEN}/reaktor.ico" COPYONLY)
|
||||
file(WRITE "${GEN}/reaktor.rc" "1 ICON \"reaktor.ico\"
|
||||
")
|
||||
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()
|
||||
set(APP_RESOURCES "${GEN}/reaktor.rc")
|
||||
elseif(UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/reaktor.desktop"
|
||||
@@ -266,11 +299,15 @@ elseif(WIN32)
|
||||
"${_a11y}/a11y_snapshot.c" "${_a11y}/a11y_win32.c")
|
||||
target_link_libraries(reaktor_a11y INTERFACE uiautomationcore ole32 oleaut32)
|
||||
elseif(APPLE)
|
||||
# Compiled here: an interface library's sources compile in the directory
|
||||
# of whoever links it, where Objective-C may not be enabled.
|
||||
enable_language(OBJC)
|
||||
add_library(reaktor_a11y_macos OBJECT "${_a11y}/a11y_macos.m")
|
||||
target_compile_options(reaktor_a11y_macos PRIVATE -fobjc-arc)
|
||||
target_compile_definitions(reaktor_a11y_macos PRIVATE REAKTOR_HAVE_NSACCESSIBILITY)
|
||||
target_link_libraries(reaktor_a11y_macos PRIVATE reaktor_runtime)
|
||||
target_sources(reaktor_a11y INTERFACE
|
||||
"${_a11y}/a11y_snapshot.c" "${_a11y}/a11y_macos.m")
|
||||
set_source_files_properties("${_a11y}/a11y_macos.m" PROPERTIES
|
||||
COMPILE_OPTIONS "-fobjc-arc")
|
||||
"${_a11y}/a11y_snapshot.c" "$<TARGET_OBJECTS:reaktor_a11y_macos>")
|
||||
target_compile_definitions(reaktor_a11y INTERFACE REAKTOR_HAVE_NSACCESSIBILITY)
|
||||
target_link_libraries(reaktor_a11y INTERFACE "-framework Cocoa")
|
||||
else()
|
||||
@@ -375,8 +412,9 @@ else()
|
||||
target_link_libraries(reaktor_text INTERFACE Mojibake::mojibake kb_text_shape)
|
||||
message(STATUS "text: shaping by kb_text_shape; direction and line breaking by mojibake")
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
add_executable(texttest tools/texttest.c core/render/nk_impl.c)
|
||||
target_link_libraries(texttest PRIVATE reaktor_headers)
|
||||
target_include_directories(texttest PRIVATE core/render core/text)
|
||||
target_link_libraries(texttest PRIVATE reaktor_text reaktor_core
|
||||
SDL3::SDL3-static)
|
||||
@@ -442,7 +480,7 @@ set(REAKTOR_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "")
|
||||
|
||||
# MIT wants each notice in every copy: they go beside the programs, unchanged.
|
||||
foreach(_lic SDL/LICENSE.txt lcui/LICENSE.TXT plutosvg/LICENSE nuklear/LICENSE
|
||||
onlay/LICENSE tinycss/LICENSE ionicons/LICENSE mojibake/LICENSE
|
||||
nukanim/LICENSE onlay/LICENSE tinycss/LICENSE ionicons/LICENSE mojibake/LICENSE
|
||||
kb/LICENSE)
|
||||
string(REGEX REPLACE "/.*" "" _who "${_lic}")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/external/${_lic}"
|
||||
@@ -475,6 +513,9 @@ function(reaktor_add_app name)
|
||||
endif()
|
||||
endforeach()
|
||||
target_link_libraries(${name} PRIVATE reaktor_runtime ${_mods})
|
||||
if(MSVC)
|
||||
target_compile_options(${name} PRIVATE /we4013)
|
||||
endif()
|
||||
set_target_properties(${name} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
if(EMSCRIPTEN)
|
||||
@@ -510,6 +551,7 @@ function(reaktor_add_app name)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(REAKTOR_SAMPLES)
|
||||
reaktor_add_app(showcase SOURCES
|
||||
samples/showcase/shell.c
|
||||
samples/showcase/shortcuts.c
|
||||
@@ -632,9 +674,7 @@ endif()
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(showcase PRIVATE /wd5287 /wd4101)
|
||||
target_compile_options(plutovg PRIVATE /wd4244 /wd4267 /wd4018)
|
||||
target_compile_definitions(showcase PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_definitions(reaktor_core PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
if(APPLE AND NOT EMSCRIPTEN)
|
||||
@@ -651,3 +691,246 @@ if(APPLE AND NOT EMSCRIPTEN)
|
||||
COMMENT "Assembling reaktor.app"
|
||||
VERBATIM)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(plutovg PRIVATE /wd4244 /wd4267 /wd4018)
|
||||
target_compile_definitions(reaktor_core PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
add_library(reaktor_modules STATIC)
|
||||
target_link_libraries(reaktor_modules PRIVATE reaktor_runtime reaktor_a11y reaktor_locale reaktor_text)
|
||||
set_target_properties(reaktor_modules PROPERTIES EXCLUDE_FROM_ALL ON)
|
||||
|
||||
set(_parts reaktor_runtime reaktor_core reaktor_modules plutosvg plutovg lcui onlay SDL3-static)
|
||||
foreach(_t mojibake_lib kb_text_shape)
|
||||
if(TARGET ${_t})
|
||||
list(APPEND _parts ${_t})
|
||||
endif()
|
||||
endforeach()
|
||||
set(_files "")
|
||||
foreach(_t IN LISTS _parts)
|
||||
list(APPEND _files "$<TARGET_FILE:${_t}>")
|
||||
endforeach()
|
||||
|
||||
# What a program links beside libreaktor: whatever its parts link that is not merged in.
|
||||
function(reaktor_outside_links)
|
||||
set(_libs "")
|
||||
set(_dirs "")
|
||||
set(_opts "")
|
||||
set(_weak "")
|
||||
set(_seen "")
|
||||
set(_refound "")
|
||||
set(_todo ${ARGN})
|
||||
while(_todo)
|
||||
list(POP_FRONT _todo _t)
|
||||
get_target_property(_real ${_t} ALIASED_TARGET)
|
||||
if(_real)
|
||||
set(_t ${_real})
|
||||
endif()
|
||||
if(_t IN_LIST _seen)
|
||||
continue()
|
||||
endif()
|
||||
list(APPEND _seen ${_t})
|
||||
get_target_property(_type ${_t} TYPE)
|
||||
get_target_property(_imported ${_t} IMPORTED)
|
||||
set(_items "")
|
||||
if(_imported AND NOT _type STREQUAL "INTERFACE_LIBRARY")
|
||||
set(_props IMPORTED_IMPLIB_RELEASE IMPORTED_IMPLIB IMPORTED_LOCATION_RELEASE
|
||||
IMPORTED_LOCATION)
|
||||
get_target_property(_cfgs ${_t} IMPORTED_CONFIGURATIONS)
|
||||
if(_cfgs)
|
||||
foreach(_c IN LISTS _cfgs)
|
||||
list(APPEND _props IMPORTED_IMPLIB_${_c} IMPORTED_LOCATION_${_c})
|
||||
endforeach()
|
||||
endif()
|
||||
set(_file "")
|
||||
foreach(_p IN LISTS _props)
|
||||
get_target_property(_f ${_t} ${_p})
|
||||
if(_f)
|
||||
set(_file "${_f}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(_file)
|
||||
list(APPEND _libs "${_file}")
|
||||
else()
|
||||
message(WARNING "libreaktor finds no file for ${_t}, which its parts link")
|
||||
endif()
|
||||
elseif(_t IN_LIST ARGN)
|
||||
get_target_property(_v ${_t} LINK_LIBRARIES)
|
||||
if(_v)
|
||||
list(APPEND _items ${_v})
|
||||
endif()
|
||||
elseif(NOT _type MATCHES "^(INTERFACE|OBJECT)_LIBRARY$")
|
||||
message(WARNING "libreaktor leaves out ${_t}, which its parts link")
|
||||
endif()
|
||||
foreach(_p INTERFACE_LINK_LIBRARIES INTERFACE_LINK_OPTIONS INTERFACE_LINK_DIRECTORIES)
|
||||
get_target_property(_v ${_t} ${_p})
|
||||
if(NOT _v)
|
||||
continue()
|
||||
endif()
|
||||
if(_p STREQUAL "INTERFACE_LINK_LIBRARIES")
|
||||
list(APPEND _items ${_v})
|
||||
elseif(_v MATCHES "\\$<")
|
||||
message(WARNING "libreaktor cannot carry ${_t}'s ${_p}: ${_v}")
|
||||
elseif(_p STREQUAL "INTERFACE_LINK_OPTIONS")
|
||||
list(APPEND _opts ${_v})
|
||||
else()
|
||||
list(APPEND _dirs ${_v})
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(_i IN LISTS _items)
|
||||
if(_i MATCHES "^\\$<LINK_ONLY:(.*)>$")
|
||||
set(_i "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
if(_i MATCHES "^\\$<(TARGET_NAME|BUILD_INTERFACE):(.*)>$")
|
||||
set(_i "${CMAKE_MATCH_2}")
|
||||
endif()
|
||||
if(_i MATCHES "^\\$<INSTALL_INTERFACE:")
|
||||
continue()
|
||||
endif()
|
||||
# A dependency's own directory may have found it: its targets are not seen here.
|
||||
if(NOT TARGET "${_i}" AND _i MATCHES "^([A-Za-z0-9_]+)::")
|
||||
set(_pkg "${CMAKE_MATCH_1}")
|
||||
if(NOT _pkg STREQUAL "PkgConfig" AND NOT _pkg IN_LIST _refound)
|
||||
list(APPEND _refound ${_pkg})
|
||||
find_package(${_pkg} QUIET)
|
||||
endif()
|
||||
endif()
|
||||
if(TARGET "${_i}")
|
||||
list(APPEND _todo "${_i}")
|
||||
elseif(_i MATCHES "^PkgConfig::(.+)$")
|
||||
set(_pc_prefix "${CMAKE_MATCH_1}")
|
||||
list(APPEND _libs ${${_pc_prefix}_LIBRARIES})
|
||||
list(APPEND _dirs ${${_pc_prefix}_LIBRARY_DIRS})
|
||||
list(APPEND _opts ${${_pc_prefix}_LDFLAGS_OTHER})
|
||||
elseif(_i MATCHES "::")
|
||||
message(WARNING "libreaktor cannot find ${_i}, which ${_t} links")
|
||||
elseif(_i MATCHES "^\\$<LINK_LIBRARY:FRAMEWORK,(.*)>$")
|
||||
list(APPEND _libs "-framework ${CMAKE_MATCH_1}")
|
||||
elseif(_i MATCHES "^\\$<LINK_LIBRARY:WEAK_FRAMEWORK,(.*)>$")
|
||||
list(APPEND _weak "${CMAKE_MATCH_1}")
|
||||
elseif(_i MATCHES "\\$<")
|
||||
message(WARNING "libreaktor cannot carry ${_t}'s link to ${_i}")
|
||||
elseif(_i)
|
||||
list(APPEND _libs "${_i}")
|
||||
endif()
|
||||
endforeach()
|
||||
endwhile()
|
||||
|
||||
# A shared library found on this machine is named, so the package finds it on another.
|
||||
set(_named "")
|
||||
foreach(_l IN LISTS _libs)
|
||||
if(IS_ABSOLUTE "${_l}" AND _l MATCHES "/lib([^/]+)\\.(so|dylib|tbd)(\\.[0-9.]+)?$")
|
||||
list(APPEND _named "${CMAKE_MATCH_1}")
|
||||
get_filename_component(_d "${_l}" DIRECTORY)
|
||||
string(FIND "${_d}" "${CMAKE_OSX_SYSROOT}" _in_sdk)
|
||||
if(NOT (CMAKE_OSX_SYSROOT AND _in_sdk EQUAL 0))
|
||||
list(APPEND _dirs "${_d}")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND _named "${_l}")
|
||||
endif()
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES _named)
|
||||
list(REMOVE_DUPLICATES _dirs)
|
||||
foreach(_d IN LISTS CMAKE_C_IMPLICIT_LINK_DIRECTORIES CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES)
|
||||
list(REMOVE_ITEM _dirs "${_d}")
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES _opts)
|
||||
list(REMOVE_DUPLICATES _weak)
|
||||
|
||||
set(_pc "")
|
||||
foreach(_d IN LISTS _dirs)
|
||||
string(APPEND _pc " -L${_d} -Wl,-rpath,${_d}")
|
||||
endforeach()
|
||||
foreach(_l IN LISTS _named)
|
||||
if(_l MATCHES "^-" OR IS_ABSOLUTE "${_l}")
|
||||
string(APPEND _pc " ${_l}")
|
||||
else()
|
||||
string(APPEND _pc " -l${_l}")
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(_w IN LISTS _weak)
|
||||
list(APPEND _opts "SHELL:-Xlinker -weak_framework -Xlinker ${_w}")
|
||||
endforeach()
|
||||
foreach(_o IN LISTS _opts)
|
||||
string(REGEX REPLACE "^SHELL:" "" _o "${_o}")
|
||||
string(REGEX REPLACE "-Xlinker -weak_framework -Xlinker " "-Wl,-weak_framework," _o "${_o}")
|
||||
string(APPEND _pc " ${_o}")
|
||||
endforeach()
|
||||
|
||||
set(REAKTOR_LINK_LIBS "${_named}" PARENT_SCOPE)
|
||||
set(REAKTOR_LINK_DIRS "${_dirs}" PARENT_SCOPE)
|
||||
set(REAKTOR_OUTSIDE_OPTIONS "${_opts}" PARENT_SCOPE)
|
||||
set(REAKTOR_PC_LIBS "${_pc}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
reaktor_outside_links(${_parts})
|
||||
set(REAKTOR_LINK_OPTIONS ${REAKTOR_OUTSIDE_OPTIONS})
|
||||
if(EMSCRIPTEN)
|
||||
set(_wasm -sALLOW_MEMORY_GROWTH=1 -sINITIAL_MEMORY=64MB -sSTACK_SIZE=4MB
|
||||
-sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sEXIT_RUNTIME=0)
|
||||
list(APPEND REAKTOR_LINK_OPTIONS ${_wasm})
|
||||
string(JOIN " " _wasm ${_wasm})
|
||||
string(APPEND REAKTOR_PC_LIBS " ${_wasm}")
|
||||
endif()
|
||||
string(JOIN " " _beside ${REAKTOR_LINK_LIBS} ${REAKTOR_LINK_DIRS} ${REAKTOR_LINK_OPTIONS})
|
||||
message(STATUS "libreaktor: a program links beside it ${_beside}")
|
||||
|
||||
if(MSVC)
|
||||
set(REAKTOR_LIB_NAME reaktor.lib)
|
||||
else()
|
||||
set(REAKTOR_LIB_NAME libreaktor.a)
|
||||
endif()
|
||||
set(_lib "${CMAKE_BINARY_DIR}/lib/${REAKTOR_LIB_NAME}")
|
||||
if(MSVC)
|
||||
set(_merge "${CMAKE_AR}" /NOLOGO "/OUT:${_lib}" ${_files})
|
||||
elseif(APPLE)
|
||||
find_program(REAKTOR_LIBTOOL NAMES libtool PATHS /usr/bin NO_DEFAULT_PATH)
|
||||
set(_merge "${REAKTOR_LIBTOOL}" -static -o "${_lib}" ${_files})
|
||||
else()
|
||||
set(_mri "CREATE ${_lib}\n")
|
||||
foreach(_f IN LISTS _files)
|
||||
string(APPEND _mri "ADDLIB ${_f}\n")
|
||||
endforeach()
|
||||
string(APPEND _mri "SAVE\nEND\n")
|
||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/reaktor.mri" CONTENT "${_mri}")
|
||||
set(_merge "${CMAKE_COMMAND}" "-DAR=${CMAKE_AR}" "-DMRI=${CMAKE_BINARY_DIR}/reaktor.mri"
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/tools/merge-lib.cmake")
|
||||
endif()
|
||||
add_custom_command(OUTPUT "${_lib}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_BINARY_DIR}/lib"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove -f "${_lib}"
|
||||
COMMAND ${_merge}
|
||||
DEPENDS ${_parts}
|
||||
COMMENT "Merging libreaktor"
|
||||
VERBATIM)
|
||||
add_custom_target(libreaktor DEPENDS "${_lib}")
|
||||
|
||||
option(REAKTOR_INSTALL "Install libreaktor's files" ${_reaktor_top})
|
||||
if(REAKTOR_INSTALL)
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_file(tools/reaktorConfig.cmake.in "${CMAKE_BINARY_DIR}/reaktorConfig.cmake" @ONLY)
|
||||
write_basic_package_version_file("${CMAKE_BINARY_DIR}/reaktorConfigVersion.cmake"
|
||||
COMPATIBILITY SameMinorVersion)
|
||||
install(FILES "${_lib}" DESTINATION lib COMPONENT libreaktor OPTIONAL)
|
||||
install(DIRECTORY include/reaktor DESTINATION include COMPONENT libreaktor)
|
||||
install(FILES "${TP}/nuklear/nuklear.h" DESTINATION include COMPONENT libreaktor)
|
||||
install(FILES "${TP}/nukanim/nukanim.h" DESTINATION include COMPONENT libreaktor)
|
||||
install(DIRECTORY "${TP}/SDL/include/SDL3" DESTINATION include COMPONENT libreaktor)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/reaktorConfig.cmake"
|
||||
"${CMAKE_BINARY_DIR}/reaktorConfigVersion.cmake"
|
||||
DESTINATION lib/cmake/reaktor COMPONENT libreaktor)
|
||||
if(NOT MSVC)
|
||||
configure_file(tools/reaktor.pc.in "${CMAKE_BINARY_DIR}/reaktor.pc" @ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/reaktor.pc" DESTINATION lib/pkgconfig
|
||||
COMPONENT libreaktor)
|
||||
endif()
|
||||
install(DIRECTORY "${CMAKE_BINARY_DIR}/licenses/" DESTINATION share/reaktor/licenses
|
||||
COMPONENT libreaktor)
|
||||
install(FILES assets/fonts/Aileron-Notice.txt DESTINATION share/reaktor/licenses
|
||||
COMPONENT libreaktor)
|
||||
install(FILES docs/NOTICE.md DESTINATION share/reaktor COMPONENT libreaktor)
|
||||
endif()
|
||||
|
||||
@@ -10,8 +10,9 @@ Tired of C having no cross-platform GUI — nothing like
|
||||
[Avalonia](https://github.com/avaloniaui/avalonia),
|
||||
[Shaft](https://github.com/ShaftUI/Shaft) or
|
||||
[Freya](https://github.com/marc2332/freya) — and of toolkits that want hundreds
|
||||
of megabytes to put a dialog on screen? I was. So I wrote Reaktor: complete
|
||||
without being big. A 2.3 MB binary, about 10 MB of RAM, and no GPU required.
|
||||
of megabytes to put a dialog on screen? No? But I was, so I wrote Reaktor:
|
||||
complete without being big. A 2.3 MB binary, about 10 MB of RAM, and no GPU
|
||||
required.
|
||||
|
||||
**[Try the showcase in your browser](https://alpaq92.github.io/Reaktor/)** — the
|
||||
same program, built to WebAssembly — or
|
||||
@@ -42,7 +43,10 @@ How, and on what, is in [PERFORMANCE.md](docs/PERFORMANCE.md).
|
||||
each language writes them.
|
||||
- **Text past Latin-1** — direction, shaping, fallback fonts and Unicode line
|
||||
breaking, so Japanese wraps properly.
|
||||
- **Animation** — 31 easing curves, keyed per widget.
|
||||
- **Animation** — tweens keyed per widget on 31 curves, springs, steps and
|
||||
béziers; keyframed clips staggered across a grid; motion paths,
|
||||
oscillators, noise and shakes; colors blended in five spaces; and text
|
||||
that arrives a glyph at a time.
|
||||
- **Modular** — accessibility, localization and text shaping each swap for a
|
||||
stub, and only what they drew stops being drawn.
|
||||
- **Windows, macOS, Linux, the BSDs and WebAssembly** from one set of sources,
|
||||
@@ -66,6 +70,11 @@ cd Reaktor
|
||||
[emsdk](https://emscripten.org)) builds the web versions into `build-wasm/`, to
|
||||
be served over HTTP.
|
||||
|
||||
To build your own application, add Reaktor with `add_subdirectory` and declare
|
||||
it with `reaktor_add_app`, or take a `libreaktor` package from the
|
||||
[releases](https://github.com/Alpaq92/Reaktor/releases/latest) and
|
||||
`find_package(reaktor)`: [In your own project](docs/DOCUMENTATION.md#in-your-own-project).
|
||||
|
||||
## Usage
|
||||
|
||||
```c
|
||||
@@ -94,6 +103,7 @@ value and position.
|
||||
software renderer. libcss, from [LCUI](https://github.com/lc-soft/LCUI), parses
|
||||
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
|
||||
[NOTICE.md](docs/NOTICE.md).
|
||||
|
||||
|
||||
@@ -132,3 +132,50 @@ colliding with Shaft itself.
|
||||
exactly one more. Skipping vsyncs that are not due looks simpler and drifts:
|
||||
to 41.6 fps in Flutter and 42.7 in Compose, which is why every arm prints
|
||||
`fps`.
|
||||
|
||||
## Bundle sizes
|
||||
|
||||
Reaktor's arm ships as one file. SDL, the CSS engine, the SVG rasterizer, the
|
||||
fonts and the default look are linked into every program, so `bench.exe`
|
||||
needs nothing beside it. Built the way the release builds them — Windows x64,
|
||||
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 |
|
||||
|
||||
The C runtime is about 300 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)).
|
||||
|
||||
The v0.2.0 downloads, as GitHub Actions built and published them:
|
||||
|
||||
| System | Architecture | Programs | libreaktor |
|
||||
| --- | --- | --- | --- |
|
||||
| Windows | x64 | 6.2 MB | 4.4 MB |
|
||||
| Windows | x86 | 5.4 MB | 3.6 MB |
|
||||
| Windows | ARM64 | 5.6 MB | 4.4 MB |
|
||||
| macOS | Apple silicon | 8.3 MB | 2.8 MB |
|
||||
| macOS | Intel | 9.2 MB | 2.9 MB |
|
||||
| Linux | x86-64 | 7.6 MB | 3.2 MB |
|
||||
| Linux | x86 | 7.2 MB | 3.1 MB |
|
||||
| Linux | ARM64 | 7.0 MB | 3.1 MB |
|
||||
| Linux | ARMv7 | 5.7 MB | 2.6 MB |
|
||||
| Linux | RISC-V 64 | 7.3 MB | 5.1 MB |
|
||||
| FreeBSD 15.1 | x86-64 | 6.4 MB | 2.9 MB |
|
||||
| FreeBSD 15.1 | ARM64 | 5.9 MB | 2.8 MB |
|
||||
| OpenBSD 7.9 | x86-64 | 6.9 MB | 3.3 MB |
|
||||
| OpenBSD 7.9 | ARM64 | 6.7 MB | 3.4 MB |
|
||||
| NetBSD 11.0 | x86-64 | 7.1 MB | 3.0 MB |
|
||||
| NetBSD 11.0 | ARM64 | 6.8 MB | 3.0 MB |
|
||||
| Web | WebAssembly | 2.7 MB | 2.0 MB |
|
||||
|
||||
A program archive holds the showcase, Notepad, Simple and, natively, the
|
||||
bench, with the files they read at runtime and every license; macOS's also
|
||||
carries the showcase as `reaktor.app`. A libreaktor archive is one static
|
||||
library with the public headers, Nuklear's and SDL's, a CMake package, a
|
||||
pkg-config file outside Windows, and the licenses. The source, every submodule
|
||||
included, is 23.2 MB.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
param([string]$Target = "", [ValidateSet("", "x64", "x86", "arm64")][string]$Arch = "")
|
||||
param([string]$Target = "", [ValidateSet("", "x64", "x86", "arm64")][string]$Arch = "",
|
||||
[string]$Out = "", [string]$Source = "")
|
||||
|
||||
$extra = @($args)
|
||||
if ($Target -like '-*') { $extra = @($Target) + $extra; $Target = "" }
|
||||
@@ -11,6 +12,8 @@ $hostArch = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchi
|
||||
}
|
||||
if (-not $Arch) { $Arch = $hostArch }
|
||||
$outDir = Join-Path $root $(if ($Arch -eq $hostArch) { "build" } else { "build-$Arch" })
|
||||
if ($Out) { $outDir = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Out) }
|
||||
$srcDir = if ($Source) { $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Source) } else { $root }
|
||||
|
||||
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
if (-not (Test-Path $vswhere)) { throw "vswhere.exe not found - install Visual Studio Build Tools" }
|
||||
@@ -42,7 +45,7 @@ $bat = Join-Path $env:TEMP "reaktor_build_$PID.bat"
|
||||
@(
|
||||
'@echo off',
|
||||
('call "' + $vcvars + '" ' + $vcarch + ' >nul 2>&1'),
|
||||
('"' + $cmake + '" -S "' + $root + '" -B "' + $outDir + '" -G Ninja ' +
|
||||
('"' + $cmake + '" -S "' + $srcDir + '" -B "' + $outDir + '" -G Ninja ' +
|
||||
'-DCMAKE_MAKE_PROGRAM="' + $ninja + '" -DCMAKE_BUILD_TYPE=Release' +
|
||||
(($extra | ForEach-Object { ' "' + $_ + '"' }) -join '')),
|
||||
'if errorlevel 1 exit /b 1',
|
||||
@@ -64,4 +67,5 @@ try {
|
||||
if ($rc -ne 0) { throw "build failed ($rc)" }
|
||||
Write-Host ""
|
||||
if ($Target) { Write-Host "built target: $Target ($Arch)" }
|
||||
elseif ($Source) { Write-Host "built: $outDir ($Arch)" }
|
||||
else { Write-Host "built: $outDir\showcase.exe (plus simple.exe and notepad.exe), $Arch" }
|
||||
|
||||
+1
-35
@@ -3,41 +3,7 @@
|
||||
|
||||
#include "nk_common.h"
|
||||
#include <stdio.h>
|
||||
|
||||
enum {
|
||||
REAKTOR_A11Y_NONE = 0,
|
||||
REAKTOR_A11Y_WINDOW,
|
||||
REAKTOR_A11Y_GROUP,
|
||||
REAKTOR_A11Y_TABLIST,
|
||||
REAKTOR_A11Y_TAB,
|
||||
REAKTOR_A11Y_BUTTON,
|
||||
REAKTOR_A11Y_LINK,
|
||||
REAKTOR_A11Y_CHECKBOX,
|
||||
REAKTOR_A11Y_RADIO,
|
||||
REAKTOR_A11Y_TEXTBOX,
|
||||
REAKTOR_A11Y_SLIDER,
|
||||
REAKTOR_A11Y_SPINBUTTON,
|
||||
REAKTOR_A11Y_PROGRESS,
|
||||
REAKTOR_A11Y_COMBOBOX,
|
||||
REAKTOR_A11Y_LISTITEM,
|
||||
REAKTOR_A11Y_TREEITEM,
|
||||
REAKTOR_A11Y_MENUBAR,
|
||||
REAKTOR_A11Y_MENU,
|
||||
REAKTOR_A11Y_MENUITEM,
|
||||
REAKTOR_A11Y_DIALOG,
|
||||
REAKTOR_A11Y_LABEL,
|
||||
REAKTOR_A11Y_ROLE_COUNT
|
||||
};
|
||||
|
||||
enum {
|
||||
REAKTOR_A11Y_FOCUSED = 1u << 0,
|
||||
REAKTOR_A11Y_CHECKED = 1u << 1,
|
||||
REAKTOR_A11Y_EXPANDED = 1u << 2,
|
||||
REAKTOR_A11Y_SELECTED = 1u << 3,
|
||||
REAKTOR_A11Y_DISABLED = 1u << 4,
|
||||
REAKTOR_A11Y_OFFSCREEN = 1u << 6,
|
||||
REAKTOR_A11Y_VOLATILE = 1u << 7
|
||||
};
|
||||
#include "reaktor/a11y.h"
|
||||
|
||||
typedef struct reaktor_a11y_node {
|
||||
unsigned id;
|
||||
|
||||
+55
-255
@@ -1,140 +1,73 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "reaktor/nuklear.h"
|
||||
#define NUKANIM_IMPLEMENTATION
|
||||
#include <nukanim.h>
|
||||
|
||||
#include "anim.h"
|
||||
|
||||
#define REAKTOR_ANIM_SLOTS 128
|
||||
typedef char reaktor_curves_are_nukanims[(unsigned)REAKTOR_EASE_BOUNCE_IN_OUT == (unsigned)NKA_EASE_IN_OUT_BOUNCE ? 1 : -1];
|
||||
|
||||
typedef struct reaktor_anim_slot {
|
||||
const void *owner;
|
||||
unsigned key;
|
||||
float from, to, value;
|
||||
float elapsed, duration;
|
||||
unsigned char curve;
|
||||
unsigned char moving;
|
||||
unsigned char started;
|
||||
unsigned char seen;
|
||||
unsigned char dead;
|
||||
} reaktor_anim_slot;
|
||||
static struct nka_context *g_anim;
|
||||
|
||||
static reaktor_anim_slot g_slot[REAKTOR_ANIM_SLOTS];
|
||||
static const void *g_scope;
|
||||
|
||||
#define PI_F 3.14159265358979323846f
|
||||
|
||||
static float
|
||||
pow_in(float t, int n)
|
||||
static void *
|
||||
anim_alloc(nk_handle h, void *old, nk_size n)
|
||||
{
|
||||
float r = t;
|
||||
int i;
|
||||
for (i = 1; i < n; i++) r *= t;
|
||||
return r;
|
||||
(void)h;
|
||||
(void)old;
|
||||
return SDL_malloc(n);
|
||||
}
|
||||
|
||||
static float
|
||||
pow_out(float t, int n)
|
||||
static void
|
||||
anim_free(nk_handle h, void *p)
|
||||
{
|
||||
float r = pow_in(1.0f - t, n);
|
||||
return 1.0f - r;
|
||||
(void)h;
|
||||
SDL_free(p);
|
||||
}
|
||||
|
||||
static float
|
||||
pow_in_out(float t, int n)
|
||||
struct nka_context *
|
||||
reaktor_anim_create(void)
|
||||
{
|
||||
if (t < 0.5f) return pow_in(2.0f * t, n) * 0.5f;
|
||||
return 1.0f - pow_in(2.0f * (1.0f - t), n) * 0.5f;
|
||||
struct nk_allocator al;
|
||||
struct nka_context *a;
|
||||
|
||||
al.userdata.ptr = NULL;
|
||||
al.alloc = anim_alloc;
|
||||
al.free = anim_free;
|
||||
a = nka_create(&al);
|
||||
/* A value starts where it is first asked to be, so it must be kept. */
|
||||
if (a) nka_set_lazy_init(a, 0);
|
||||
return a;
|
||||
}
|
||||
|
||||
static float
|
||||
bounce_out(float t)
|
||||
void
|
||||
reaktor_anim_destroy(struct nka_context *a)
|
||||
{
|
||||
const float n = 7.5625f, d = 2.75f;
|
||||
if (g_anim == a) g_anim = NULL;
|
||||
nka_destroy(a);
|
||||
}
|
||||
|
||||
if (t < 1.0f / d) return n * t * t;
|
||||
if (t < 2.0f / d) { t -= 1.5f / d; return n * t * t + 0.75f; }
|
||||
if (t < 2.5f / d) { t -= 2.25f / d; return n * t * t + 0.9375f; }
|
||||
t -= 2.625f / d;
|
||||
return n * t * t + 0.984375f;
|
||||
void
|
||||
reaktor_anim_frame(struct nka_context *a, float dt_ms)
|
||||
{
|
||||
g_anim = a;
|
||||
if (dt_ms < 0.0f) dt_ms = 0.0f;
|
||||
if (dt_ms > 64.0f) dt_ms = 64.0f;
|
||||
nka_update(a, dt_ms / 1000.0f);
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_anim_settle(void)
|
||||
{
|
||||
if (!g_anim) return 0;
|
||||
nka_gc(g_anim, 600);
|
||||
return nka_busy(g_anim);
|
||||
}
|
||||
|
||||
float
|
||||
reaktor_ease_at(unsigned char curve, float t)
|
||||
{
|
||||
const float c1 = 1.70158f;
|
||||
const float c2 = c1 * 1.525f;
|
||||
const float c3 = c1 + 1.0f;
|
||||
const float e1 = 2.0f * PI_F / 3.0f;
|
||||
const float e2 = 2.0f * PI_F / 4.5f;
|
||||
|
||||
if (t <= 0.0f) return 0.0f;
|
||||
if (t >= 1.0f) return 1.0f;
|
||||
|
||||
switch (curve) {
|
||||
case REAKTOR_EASE_LINEAR: return t;
|
||||
|
||||
case REAKTOR_EASE_QUAD_IN: return pow_in(t, 2);
|
||||
case REAKTOR_EASE_QUAD_OUT: return pow_out(t, 2);
|
||||
case REAKTOR_EASE_QUAD_IN_OUT: return pow_in_out(t, 2);
|
||||
case REAKTOR_EASE_CUBIC_IN: return pow_in(t, 3);
|
||||
case REAKTOR_EASE_CUBIC_OUT: return pow_out(t, 3);
|
||||
case REAKTOR_EASE_CUBIC_IN_OUT: return pow_in_out(t, 3);
|
||||
case REAKTOR_EASE_QUART_IN: return pow_in(t, 4);
|
||||
case REAKTOR_EASE_QUART_OUT: return pow_out(t, 4);
|
||||
case REAKTOR_EASE_QUART_IN_OUT: return pow_in_out(t, 4);
|
||||
case REAKTOR_EASE_QUINT_IN: return pow_in(t, 5);
|
||||
case REAKTOR_EASE_QUINT_OUT: return pow_out(t, 5);
|
||||
case REAKTOR_EASE_QUINT_IN_OUT: return pow_in_out(t, 5);
|
||||
|
||||
case REAKTOR_EASE_SINE_IN: return 1.0f - cosf(t * PI_F * 0.5f);
|
||||
case REAKTOR_EASE_SINE_OUT: return sinf(t * PI_F * 0.5f);
|
||||
case REAKTOR_EASE_SINE_IN_OUT: return -(cosf(PI_F * t) - 1.0f) * 0.5f;
|
||||
|
||||
case REAKTOR_EASE_EXPO_IN: return powf(2.0f, 10.0f * t - 10.0f);
|
||||
case REAKTOR_EASE_EXPO_OUT: return 1.0f - powf(2.0f, -10.0f * t);
|
||||
case REAKTOR_EASE_EXPO_IN_OUT:
|
||||
return t < 0.5f ? powf(2.0f, 20.0f * t - 10.0f) * 0.5f
|
||||
: (2.0f - powf(2.0f, -20.0f * t + 10.0f)) * 0.5f;
|
||||
|
||||
case REAKTOR_EASE_CIRC_IN: return 1.0f - sqrtf(1.0f - t * t);
|
||||
case REAKTOR_EASE_CIRC_OUT: return sqrtf(1.0f - (t - 1.0f) * (t - 1.0f));
|
||||
case REAKTOR_EASE_CIRC_IN_OUT:
|
||||
return t < 0.5f
|
||||
? (1.0f - sqrtf(1.0f - 4.0f * t * t)) * 0.5f
|
||||
: (sqrtf(1.0f - (-2.0f * t + 2.0f) * (-2.0f * t + 2.0f))
|
||||
+ 1.0f) * 0.5f;
|
||||
|
||||
case REAKTOR_EASE_BACK_IN: return c3 * t * t * t - c1 * t * t;
|
||||
case REAKTOR_EASE_BACK_OUT: {
|
||||
float u = t - 1.0f;
|
||||
return 1.0f + c3 * u * u * u + c1 * u * u;
|
||||
}
|
||||
case REAKTOR_EASE_BACK_IN_OUT:
|
||||
return t < 0.5f
|
||||
? (4.0f * t * t * ((c2 + 1.0f) * 2.0f * t - c2)) * 0.5f
|
||||
: ((2.0f * t - 2.0f) * (2.0f * t - 2.0f)
|
||||
* ((c2 + 1.0f) * (2.0f * t - 2.0f) + c2) + 2.0f) * 0.5f;
|
||||
|
||||
case REAKTOR_EASE_ELASTIC_IN:
|
||||
return -powf(2.0f, 10.0f * t - 10.0f)
|
||||
* sinf((t * 10.0f - 10.75f) * e1);
|
||||
case REAKTOR_EASE_ELASTIC_OUT:
|
||||
return powf(2.0f, -10.0f * t) * sinf((t * 10.0f - 0.75f) * e1) + 1.0f;
|
||||
case REAKTOR_EASE_ELASTIC_IN_OUT:
|
||||
return t < 0.5f
|
||||
? -(powf(2.0f, 20.0f * t - 10.0f)
|
||||
* sinf((20.0f * t - 11.125f) * e2)) * 0.5f
|
||||
: (powf(2.0f, -20.0f * t + 10.0f)
|
||||
* sinf((20.0f * t - 11.125f) * e2)) * 0.5f + 1.0f;
|
||||
|
||||
case REAKTOR_EASE_BOUNCE_IN: return 1.0f - bounce_out(1.0f - t);
|
||||
case REAKTOR_EASE_BOUNCE_OUT: return bounce_out(t);
|
||||
case REAKTOR_EASE_BOUNCE_IN_OUT:
|
||||
return t < 0.5f ? (1.0f - bounce_out(1.0f - 2.0f * t)) * 0.5f
|
||||
: (1.0f + bounce_out(2.0f * t - 1.0f)) * 0.5f;
|
||||
|
||||
default: return t;
|
||||
}
|
||||
return nka_eval_preset(curve, t);
|
||||
}
|
||||
|
||||
const char *
|
||||
@@ -156,150 +89,17 @@ reaktor_ease_name(unsigned char curve)
|
||||
return curve < REAKTOR_EASE_COUNT ? n[curve] : "?";
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_anim_scope(const void *owner)
|
||||
float
|
||||
reaktor_animate(unsigned id, unsigned channel, float to, float ms,
|
||||
unsigned char curve)
|
||||
{
|
||||
g_scope = owner;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
key_of(unsigned id, unsigned channel)
|
||||
{
|
||||
unsigned k = id * 2654435761u + channel * 0x9e3779b9u +
|
||||
(unsigned)(size_t)g_scope * 0x85ebca6bu;
|
||||
k ^= k >> 15;
|
||||
return k ? k : 1u;
|
||||
}
|
||||
|
||||
static reaktor_anim_slot *
|
||||
slot_of(unsigned key, const void *owner, int make)
|
||||
{
|
||||
unsigned i = key & (REAKTOR_ANIM_SLOTS - 1);
|
||||
unsigned n;
|
||||
|
||||
for (n = 0; n < REAKTOR_ANIM_SLOTS; n++) {
|
||||
reaktor_anim_slot *s = &g_slot[i];
|
||||
|
||||
if (s->key == key && s->owner == owner) return s;
|
||||
if (!s->key) {
|
||||
if (!make) return NULL;
|
||||
s->key = key;
|
||||
s->owner = owner;
|
||||
return s;
|
||||
}
|
||||
i = (i + 1) & (REAKTOR_ANIM_SLOTS - 1);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
compact(void)
|
||||
{
|
||||
reaktor_anim_slot old[REAKTOR_ANIM_SLOTS];
|
||||
int i;
|
||||
|
||||
SDL_memcpy(old, g_slot, sizeof(old));
|
||||
SDL_memset(g_slot, 0, sizeof(g_slot));
|
||||
for (i = 0; i < REAKTOR_ANIM_SLOTS; i++) {
|
||||
reaktor_anim_slot *s;
|
||||
|
||||
if (!old[i].key || old[i].dead) continue;
|
||||
s = slot_of(old[i].key, old[i].owner, 1);
|
||||
if (s) *s = old[i];
|
||||
}
|
||||
if (ms <= 0.0f || !g_anim) return to;
|
||||
return nka_tween_float(g_anim, id, channel, to, ms / 1000.0f,
|
||||
nka_ease(curve), NKA_POLICY_CROSSFADE, to);
|
||||
}
|
||||
|
||||
float
|
||||
reaktor_anim_progress(unsigned id, unsigned channel)
|
||||
{
|
||||
reaktor_anim_slot *s = slot_of(key_of(id, channel), g_scope, 0);
|
||||
|
||||
if (!s || !s->moving || s->duration <= 0.0f) return -1.0f;
|
||||
return s->elapsed / s->duration;
|
||||
}
|
||||
|
||||
float
|
||||
reaktor_animate(unsigned id, unsigned channel, float to, float ms,
|
||||
unsigned char curve)
|
||||
{
|
||||
reaktor_anim_slot *s;
|
||||
unsigned key;
|
||||
|
||||
if (ms <= 0.0f) return to;
|
||||
|
||||
key = key_of(id, channel);
|
||||
s = slot_of(key, g_scope, 1);
|
||||
if (!s) return to;
|
||||
s->seen = 1;
|
||||
|
||||
if (!s->started) {
|
||||
s->started = 1;
|
||||
s->from = s->to = s->value = to;
|
||||
s->curve = curve;
|
||||
return to;
|
||||
}
|
||||
|
||||
if (to != s->to) {
|
||||
s->from = s->value;
|
||||
s->to = to;
|
||||
s->elapsed = 0.0f;
|
||||
s->duration = ms;
|
||||
s->curve = curve;
|
||||
s->moving = 1;
|
||||
}
|
||||
return s->value;
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_anim_tick(float dt_ms)
|
||||
{
|
||||
int i, moving = 0;
|
||||
|
||||
if (dt_ms < 0.0f) dt_ms = 0.0f;
|
||||
if (dt_ms > 64.0f) dt_ms = 64.0f;
|
||||
|
||||
for (i = 0; i < REAKTOR_ANIM_SLOTS; i++) {
|
||||
reaktor_anim_slot *s = &g_slot[i];
|
||||
|
||||
if (!s->key || !s->moving || s->owner != g_scope) continue;
|
||||
s->elapsed += dt_ms;
|
||||
if (s->elapsed >= s->duration) {
|
||||
s->elapsed = s->duration;
|
||||
s->value = s->to;
|
||||
s->moving = 0;
|
||||
} else {
|
||||
float t = s->elapsed / s->duration;
|
||||
s->value = s->from
|
||||
+ (s->to - s->from) * reaktor_ease_at(s->curve, t);
|
||||
}
|
||||
/* The landing step needs a frame too. */
|
||||
moving++;
|
||||
}
|
||||
return moving;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_anim_evict(const reaktor_a11y_change *c, int n)
|
||||
{
|
||||
int i, removed = 0;
|
||||
|
||||
for (i = 0; c && i < n; i++) {
|
||||
unsigned ch;
|
||||
|
||||
if (c[i].kind != REAKTOR_A11Y_REMOVED) continue;
|
||||
for (ch = 0; ch < 16u; ch++) {
|
||||
reaktor_anim_slot *s = slot_of(key_of(c[i].id, ch), g_scope, 0);
|
||||
if (s && !s->dead) { s->dead = 1; removed++; }
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < REAKTOR_ANIM_SLOTS; i++) {
|
||||
reaktor_anim_slot *s = &g_slot[i];
|
||||
|
||||
if (!s->key || s->dead || s->owner != g_scope) continue;
|
||||
if (!s->seen) { s->dead = 1; removed++; continue; }
|
||||
s->seen = 0;
|
||||
}
|
||||
|
||||
if (removed) compact();
|
||||
return g_anim ? nka_tween_progress(g_anim, id, channel) : -1.0f;
|
||||
}
|
||||
|
||||
+7
-34
@@ -1,42 +1,15 @@
|
||||
#ifndef REAKTOR_ANIM_H
|
||||
#define REAKTOR_ANIM_H
|
||||
|
||||
#include "a11y.h"
|
||||
#include "reaktor/anim.h"
|
||||
|
||||
enum {
|
||||
REAKTOR_EASE_LINEAR = 0,
|
||||
struct nka_context *reaktor_anim_create(void);
|
||||
void reaktor_anim_destroy(struct nka_context *a);
|
||||
|
||||
REAKTOR_EASE_QUAD_IN, REAKTOR_EASE_QUAD_OUT, REAKTOR_EASE_QUAD_IN_OUT,
|
||||
REAKTOR_EASE_CUBIC_IN, REAKTOR_EASE_CUBIC_OUT, REAKTOR_EASE_CUBIC_IN_OUT,
|
||||
REAKTOR_EASE_QUART_IN, REAKTOR_EASE_QUART_OUT, REAKTOR_EASE_QUART_IN_OUT,
|
||||
REAKTOR_EASE_QUINT_IN, REAKTOR_EASE_QUINT_OUT, REAKTOR_EASE_QUINT_IN_OUT,
|
||||
|
||||
REAKTOR_EASE_SINE_IN, REAKTOR_EASE_SINE_OUT, REAKTOR_EASE_SINE_IN_OUT,
|
||||
REAKTOR_EASE_EXPO_IN, REAKTOR_EASE_EXPO_OUT, REAKTOR_EASE_EXPO_IN_OUT,
|
||||
REAKTOR_EASE_CIRC_IN, REAKTOR_EASE_CIRC_OUT, REAKTOR_EASE_CIRC_IN_OUT,
|
||||
|
||||
REAKTOR_EASE_BACK_IN, REAKTOR_EASE_BACK_OUT, REAKTOR_EASE_BACK_IN_OUT,
|
||||
REAKTOR_EASE_ELASTIC_IN, REAKTOR_EASE_ELASTIC_OUT,
|
||||
REAKTOR_EASE_ELASTIC_IN_OUT,
|
||||
REAKTOR_EASE_BOUNCE_IN, REAKTOR_EASE_BOUNCE_OUT,
|
||||
REAKTOR_EASE_BOUNCE_IN_OUT,
|
||||
|
||||
REAKTOR_EASE_COUNT
|
||||
};
|
||||
|
||||
float reaktor_ease_at(unsigned char curve, float t);
|
||||
const char *reaktor_ease_name(unsigned char curve);
|
||||
|
||||
float reaktor_animate(unsigned id, unsigned channel, float to,
|
||||
float ms, unsigned char curve);
|
||||
|
||||
float reaktor_anim_progress(unsigned id, unsigned channel);
|
||||
|
||||
void reaktor_anim_scope(const void *owner);
|
||||
|
||||
int reaktor_anim_tick(float dt_ms);
|
||||
|
||||
void reaktor_anim_evict(const reaktor_a11y_change *changes, int n);
|
||||
/* Before the page: makes a the context reaktor_animate uses and moves its time on. */
|
||||
void reaktor_anim_frame(struct nka_context *a, float dt_ms);
|
||||
|
||||
/* After the page: nonzero while something it drew is still moving. */
|
||||
int reaktor_anim_settle(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,8 +39,6 @@ void reaktor_free(void *p);
|
||||
|
||||
void reaktor_release_free_memory(void);
|
||||
|
||||
#define REAKTOR_BRAND "#6b4ee6"
|
||||
|
||||
#define REAKTOR_MARK "assets/icons/reaktor-icon.svg"
|
||||
|
||||
#endif
|
||||
|
||||
+172
-10
@@ -423,6 +423,111 @@ static void convert_units(const char *s, size_t len, float rem_px, float em_px,
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct calc_val { double v; int px; } calc_val;
|
||||
typedef struct calc_in { const char *s; size_t i, n; } calc_in;
|
||||
|
||||
static void calc_space(calc_in *c)
|
||||
{
|
||||
while (c->i < c->n && isspace((unsigned char)c->s[c->i])) c->i++;
|
||||
}
|
||||
|
||||
static int calc_sum(calc_in *c, calc_val *out);
|
||||
|
||||
static int calc_atom(calc_in *c, calc_val *out)
|
||||
{
|
||||
char *end;
|
||||
|
||||
calc_space(c);
|
||||
if (c->i < c->n && c->s[c->i] == '-') {
|
||||
c->i++;
|
||||
if (!calc_atom(c, out)) return 0;
|
||||
out->v = -out->v;
|
||||
return 1;
|
||||
}
|
||||
if (c->i + 5 <= c->n && strncmp(c->s + c->i, "calc(", 5) == 0) c->i += 4;
|
||||
if (c->i < c->n && c->s[c->i] == '(') {
|
||||
c->i++;
|
||||
if (!calc_sum(c, out)) return 0;
|
||||
calc_space(c);
|
||||
if (c->i >= c->n || c->s[c->i] != ')') return 0;
|
||||
c->i++;
|
||||
return 1;
|
||||
}
|
||||
if (c->i >= c->n || (!isdigit((unsigned char)c->s[c->i]) && c->s[c->i] != '.'))
|
||||
return 0;
|
||||
out->v = strtod(c->s + c->i, &end);
|
||||
c->i = (size_t)(end - c->s);
|
||||
out->px = c->i + 2 <= c->n && strncmp(c->s + c->i, "px", 2) == 0;
|
||||
if (out->px) c->i += 2;
|
||||
return c->i >= c->n || !(isalpha((unsigned char)c->s[c->i]) || c->s[c->i] == '%');
|
||||
}
|
||||
|
||||
static int calc_product(calc_in *c, calc_val *out)
|
||||
{
|
||||
calc_val r;
|
||||
char op;
|
||||
|
||||
if (!calc_atom(c, out)) return 0;
|
||||
for (;;) {
|
||||
calc_space(c);
|
||||
if (c->i >= c->n || (c->s[c->i] != '*' && c->s[c->i] != '/')) return 1;
|
||||
op = c->s[c->i++];
|
||||
if (!calc_atom(c, &r)) return 0;
|
||||
if (op == '*') {
|
||||
if (out->px && r.px) return 0;
|
||||
out->v *= r.v;
|
||||
out->px |= r.px;
|
||||
} else {
|
||||
if (r.px || r.v == 0.0) return 0;
|
||||
out->v /= r.v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int calc_sum(calc_in *c, calc_val *out)
|
||||
{
|
||||
calc_val r;
|
||||
char op;
|
||||
|
||||
if (!calc_product(c, out)) return 0;
|
||||
for (;;) {
|
||||
calc_space(c);
|
||||
if (c->i >= c->n || (c->s[c->i] != '+' && c->s[c->i] != '-')) return 1;
|
||||
op = c->s[c->i++];
|
||||
if (!calc_product(c, &r) || r.px != out->px) return 0;
|
||||
out->v += op == '+' ? r.v : -r.v;
|
||||
}
|
||||
}
|
||||
|
||||
/* calc() over pixels and plain numbers; one with any other unit is left. */
|
||||
static void calc_values(buf *b)
|
||||
{
|
||||
static const char fn[] = "calc(";
|
||||
size_t from = 0;
|
||||
char *at;
|
||||
|
||||
while (b->p && (at = strstr(b->p + from, fn))) {
|
||||
size_t s = (size_t)(at - b->p);
|
||||
calc_in c;
|
||||
calc_val v;
|
||||
char out[64];
|
||||
buf r;
|
||||
|
||||
c.s = b->p;
|
||||
c.i = s;
|
||||
c.n = b->len;
|
||||
if (!calc_atom(&c, &v)) { from = s + 1; continue; }
|
||||
snprintf(out, sizeof(out), v.px ? "%gpx" : "%g", v.v);
|
||||
memset(&r, 0, sizeof(r));
|
||||
buf_add(&r, b->p, s);
|
||||
buf_str(&r, out);
|
||||
buf_add(&r, b->p + c.i, b->len - c.i);
|
||||
free(b->p);
|
||||
*b = r;
|
||||
from = s + strlen(out);
|
||||
}
|
||||
}
|
||||
|
||||
static void strip_comments(char *s)
|
||||
{
|
||||
char *r = s, *w = s;
|
||||
@@ -446,12 +551,32 @@ static void trim(const char *s, size_t *start, size_t *end)
|
||||
while (*end > *start && isspace((unsigned char)s[*end - 1])) (*end)--;
|
||||
}
|
||||
|
||||
/* Every widget that asks is enabled; a disabled one asks for :disabled. */
|
||||
static int enabled_at(const char *s, size_t len, size_t i)
|
||||
{
|
||||
return len - i >= 8 && memcmp(s + i, ":enabled", 8) == 0 &&
|
||||
(i + 8 == len || !(isalnum((unsigned char)s[i + 8]) || s[i + 8] == '-'));
|
||||
}
|
||||
|
||||
static int names_enabled(const char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
if (enabled_at(s, len, i)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t selector_rewrite(const char *s, size_t len, char *out,
|
||||
size_t cap)
|
||||
{
|
||||
size_t i = 0, n = 0;
|
||||
|
||||
while (i < len) {
|
||||
if (enabled_at(s, len, i)) {
|
||||
i += 8;
|
||||
continue;
|
||||
}
|
||||
if (s[i] != '[') {
|
||||
if (n + 1 >= cap) return 0;
|
||||
out[n++] = s[i++];
|
||||
@@ -461,7 +586,15 @@ static size_t selector_rewrite(const char *s, size_t len, char *out,
|
||||
size_t j = i + 1, eq, ve, vs;
|
||||
|
||||
while (j < len && s[j] != ']' && s[j] != '=') j++;
|
||||
if (j >= len || s[j] != '=') return 0;
|
||||
if (j >= len) return 0;
|
||||
if (s[j] == ']') {
|
||||
if (j == i + 1 || n + 1 + (j - i - 1) >= cap) return 0;
|
||||
out[n++] = '.';
|
||||
memcpy(out + n, s + i + 1, j - i - 1);
|
||||
n += j - i - 1;
|
||||
i = j + 1;
|
||||
continue;
|
||||
}
|
||||
if (j > i + 1 && strchr("^$*|~", s[j - 1])) return 0;
|
||||
eq = j;
|
||||
vs = eq + 1;
|
||||
@@ -501,6 +634,32 @@ static int selector_unsupported(const char *s, size_t len)
|
||||
return len == 0;
|
||||
}
|
||||
|
||||
static int name_start(char c) { return c == '.' || c == ':' || c == '#'; }
|
||||
|
||||
static size_t name_end(const char *s, size_t i, size_t len)
|
||||
{
|
||||
for (i++; i < len && !name_start(s[i]) && !isspace((unsigned char)s[i]); i++) {}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* LCUI goes on using a node's list after freeing it when one compound names
|
||||
* the same class or pseudo-class twice - as two :not() do, read its way. */
|
||||
static int selector_repeats(const char *s, size_t len)
|
||||
{
|
||||
size_t a, ae, b, be;
|
||||
|
||||
for (a = 0; a < len; a = ae) {
|
||||
if (!name_start(s[a])) { ae = a + 1; continue; }
|
||||
ae = name_end(s, a, len);
|
||||
for (b = ae; b < len && !isspace((unsigned char)s[b]); b = be) {
|
||||
if (!name_start(s[b])) { be = b + 1; continue; }
|
||||
be = name_end(s, b, len);
|
||||
if (be - b == ae - a && memcmp(s + a, s + b, ae - a) == 0) return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_theme_selector(const char *s, size_t len, const char *theme)
|
||||
{
|
||||
char want[64];
|
||||
@@ -663,6 +822,7 @@ static void emit_one(void *c, const char *p, size_t plen,
|
||||
} else {
|
||||
convert_units(tmp.p ? tmp.p : "", tmp.len,
|
||||
ctx->rem_px, ctx->em_px, &conv);
|
||||
calc_values(&conv);
|
||||
}
|
||||
|
||||
buf_add(ctx->out, p, plen);
|
||||
@@ -835,17 +995,19 @@ static char *flatten(char *src, const char *theme, reaktor_cssvars **out_vars)
|
||||
if (part < sel_e) part++;
|
||||
trim(src, &ps, &pe);
|
||||
if (selector_unsupported(src + ps, pe - ps)) continue;
|
||||
if (memchr(src + ps, '[', pe - ps)) {
|
||||
char rw[256];
|
||||
size_t rn = selector_rewrite(src + ps, pe - ps,
|
||||
rw, sizeof(rw));
|
||||
{
|
||||
char rw[256];
|
||||
const char *t = src + ps;
|
||||
size_t tn = pe - ps;
|
||||
|
||||
if (!rn) continue;
|
||||
if (memchr(t, '[', tn) || names_enabled(t, tn)) {
|
||||
tn = selector_rewrite(t, tn, rw, sizeof(rw));
|
||||
t = rw;
|
||||
if (!tn) continue;
|
||||
}
|
||||
if (selector_repeats(t, tn)) continue;
|
||||
if (n_emitted) buf_str(&sel, ", ");
|
||||
buf_add(&sel, rw, rn);
|
||||
} else {
|
||||
if (n_emitted) buf_str(&sel, ", ");
|
||||
buf_add(&sel, src + ps, pe - ps);
|
||||
buf_add(&sel, t, tn);
|
||||
}
|
||||
n_emitted++;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ static struct {
|
||||
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])
|
||||
@@ -64,6 +65,7 @@ static int style_load(const char *const *css_paths, int count,
|
||||
css_init_library();
|
||||
}
|
||||
g.cache_n = 0;
|
||||
g.generation++;
|
||||
base_reset();
|
||||
|
||||
reaktor_cssvars_free(g.vars);
|
||||
@@ -132,6 +134,11 @@ void reaktor_style_shutdown(void)
|
||||
g.cache_n = 0;
|
||||
}
|
||||
|
||||
unsigned reaktor_style_generation(void)
|
||||
{
|
||||
return g.generation;
|
||||
}
|
||||
|
||||
int reaktor_style_token(const char *name, unsigned char rgba[4])
|
||||
{
|
||||
return reaktor_cssvars_color(g.vars, name, rgba);
|
||||
@@ -159,6 +166,7 @@ static void resolve(const char *selector, reaktor_style *out)
|
||||
css_computed_style_t computed;
|
||||
|
||||
memset(out, 0, sizeof(*out));
|
||||
out->opacity = 1.0f;
|
||||
if (!g.ready || !selector) return;
|
||||
|
||||
sel = css_selector_create(selector);
|
||||
@@ -235,6 +243,11 @@ static void resolve(const char *selector, reaktor_style *out)
|
||||
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: {
|
||||
|
||||
+3
-32
@@ -1,41 +1,12 @@
|
||||
#ifndef REAKTOR_STYLE_H
|
||||
#define REAKTOR_STYLE_H
|
||||
|
||||
enum { REAKTOR_SIDE_TOP = 0, REAKTOR_SIDE_RIGHT, REAKTOR_SIDE_BOTTOM, REAKTOR_SIDE_LEFT };
|
||||
enum { REAKTOR_CORNER_TL = 0, REAKTOR_CORNER_TR, REAKTOR_CORNER_BR, REAKTOR_CORNER_BL };
|
||||
|
||||
typedef struct reaktor_style {
|
||||
unsigned char bg[4];
|
||||
unsigned char fg[4];
|
||||
unsigned char border_col[4];
|
||||
|
||||
float border;
|
||||
float rounding;
|
||||
float pad_x, pad_y;
|
||||
|
||||
float pad[4];
|
||||
float border_w[4];
|
||||
float radius[4];
|
||||
float margin[4];
|
||||
|
||||
float width, height;
|
||||
float min_width, min_height;
|
||||
float max_width, max_height;
|
||||
float line_height;
|
||||
|
||||
int font_px;
|
||||
int bold;
|
||||
int matched;
|
||||
} reaktor_style;
|
||||
#include "reaktor/style.h"
|
||||
|
||||
int reaktor_style_init(const char *const *css_paths, int count,
|
||||
const char *theme);
|
||||
void reaktor_style_shutdown(void);
|
||||
|
||||
void reaktor_style_get(const char *selector, reaktor_style *out);
|
||||
|
||||
void reaktor_style_darken(unsigned char rgba[4], float amount);
|
||||
|
||||
int reaktor_style_token(const char *name, unsigned char rgba[4]);
|
||||
/* Counts loads, so a layout can tell its sizes come from an older sheet. */
|
||||
unsigned reaktor_style_generation(void);
|
||||
|
||||
#endif
|
||||
|
||||
+11
-1
@@ -27,6 +27,7 @@ typedef struct locale_catalog {
|
||||
static locale_catalog g_cat[LOCALE_MAX];
|
||||
static int g_count;
|
||||
static int g_current = -1;
|
||||
static int g_system;
|
||||
|
||||
static int
|
||||
by_code(const void *a, const void *b)
|
||||
@@ -157,6 +158,7 @@ release(void)
|
||||
}
|
||||
g_count = 0;
|
||||
g_current = -1;
|
||||
g_system = 0;
|
||||
}
|
||||
|
||||
#ifdef REAKTOR_LOCALE_EMBEDDED
|
||||
@@ -245,13 +247,21 @@ reaktor_locale_name(int index)
|
||||
int
|
||||
reaktor_locale_set(const char *code)
|
||||
{
|
||||
int i = reaktor_locale_find(code);
|
||||
int follow = !code;
|
||||
int i = reaktor_locale_find(follow ? reaktor_locale_system_code() : code);
|
||||
|
||||
if (i < 0) return 0;
|
||||
g_current = i;
|
||||
g_system = follow;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_locale_system(void)
|
||||
{
|
||||
return g_system;
|
||||
}
|
||||
|
||||
const char *
|
||||
reaktor_locale_current(void)
|
||||
{
|
||||
|
||||
+1
-27
@@ -1,35 +1,9 @@
|
||||
#ifndef REAKTOR_LOCALE_H
|
||||
#define REAKTOR_LOCALE_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void reaktor_locale_start(const char *lang);
|
||||
int reaktor_locale_count(void);
|
||||
const char *reaktor_locale_code(int index);
|
||||
const char *reaktor_locale_name(int index);
|
||||
int reaktor_locale_set(const char *code);
|
||||
const char *reaktor_locale_current(void);
|
||||
|
||||
const char *reaktor_tr(const char *key);
|
||||
const char *reaktor_trn(const char *key, unsigned long n, char *buf, size_t cap);
|
||||
#include "reaktor/locale.h"
|
||||
|
||||
/* The caller SDL_frees them. */
|
||||
unsigned *reaktor_locale_glyphs(const unsigned char *ttf);
|
||||
|
||||
const char *reaktor_format_number(char *buf, size_t cap, double value,
|
||||
int decimals);
|
||||
const char *reaktor_format_money(char *buf, size_t cap, double amount,
|
||||
const char *currency);
|
||||
|
||||
enum {
|
||||
REAKTOR_DATE_SHORT,
|
||||
REAKTOR_DATE_LONG,
|
||||
REAKTOR_DATE_FULL,
|
||||
REAKTOR_TIME_SHORT
|
||||
};
|
||||
|
||||
struct tm;
|
||||
const char *reaktor_format_date(char *buf, size_t cap, const struct tm *t,
|
||||
int style);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
int reaktor_locale_init(void);
|
||||
int reaktor_locale_find(const char *code);
|
||||
const char *reaktor_locale_system_code(void);
|
||||
int reaktor_locale_codepoints(unsigned *out, int cap);
|
||||
long reaktor_plural_eval(const char *expr, unsigned long n);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ int reaktor_locale_count(void) { return 0; }
|
||||
const char *reaktor_locale_code(int i) { (void)i; return NULL; }
|
||||
const char *reaktor_locale_name(int i) { (void)i; return NULL; }
|
||||
int reaktor_locale_set(const char *c) { (void)c; return 0; }
|
||||
int reaktor_locale_system(void) { return 0; }
|
||||
const char *reaktor_locale_current(void) { return ""; }
|
||||
const char *reaktor_tr(const char *key) { return key; }
|
||||
|
||||
|
||||
@@ -6,20 +6,26 @@
|
||||
void
|
||||
reaktor_locale_start(const char *lang)
|
||||
{
|
||||
SDL_Locale **pref;
|
||||
int i, n = 0;
|
||||
|
||||
if (reaktor_locale_init() <= 0) return;
|
||||
if (lang) {
|
||||
if (reaktor_locale_set(lang)) return;
|
||||
SDL_Log("no catalog for --lang %s", lang);
|
||||
}
|
||||
reaktor_locale_set(NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
reaktor_locale_system_code(void)
|
||||
{
|
||||
SDL_Locale **pref;
|
||||
int i, at = -1, n = 0;
|
||||
|
||||
pref = SDL_GetPreferredLocales(&n);
|
||||
for (i = 0; pref && i < n; i++)
|
||||
if (pref[i] && reaktor_locale_set(pref[i]->language)) break;
|
||||
for (i = 0; pref && i < n && at < 0; i++)
|
||||
if (pref[i]) at = reaktor_locale_find(pref[i]->language);
|
||||
SDL_free(pref);
|
||||
if (!reaktor_locale_current()[0] && !reaktor_locale_set("en"))
|
||||
reaktor_locale_set(reaktor_locale_code(0));
|
||||
if (at < 0) at = reaktor_locale_find("en");
|
||||
return reaktor_locale_code(at < 0 ? 0 : at);
|
||||
}
|
||||
|
||||
unsigned *
|
||||
|
||||
@@ -196,6 +196,12 @@ icon(App *app, const char *src, int px)
|
||||
return icon_over(app, src, px, 2.0f);
|
||||
}
|
||||
|
||||
struct nk_image
|
||||
reaktor_svg(App *app, const char *src, int px)
|
||||
{
|
||||
return icon(app, src, px);
|
||||
}
|
||||
|
||||
void
|
||||
image_centred(struct nk_context *ctx, struct nk_image im, int px)
|
||||
{
|
||||
@@ -258,6 +264,18 @@ round_mask(App *app, int r, int t)
|
||||
p[3] = (unsigned char)((hit * 255) / (ss * ss));
|
||||
}
|
||||
}
|
||||
/* A border's straight runs are cut from the middle texels, which sit
|
||||
* half a texel off the arc's apex, so they carry the straight band. */
|
||||
if (t > 0) {
|
||||
for (y = 0; y < d; y++)
|
||||
for (x = r - 1; x <= r; x++)
|
||||
px[(size_t)y * surf->pitch + x * 4 + 3] =
|
||||
y < t || y >= d - t ? 255 : 0;
|
||||
for (x = 0; x < d; x++)
|
||||
for (y = r - 1; y <= r; y++)
|
||||
px[(size_t)y * surf->pitch + x * 4 + 3] =
|
||||
x < t || x >= d - t ? 255 : 0;
|
||||
}
|
||||
tex = SDL_CreateTextureFromSurface(app->ren, surf);
|
||||
SDL_DestroySurface(surf);
|
||||
}
|
||||
@@ -357,6 +375,74 @@ reaktor_render(App *app)
|
||||
? NK_ANTI_ALIASING_ON : NK_ANTI_ALIASING_OFF);
|
||||
}
|
||||
|
||||
/* The last command so far, or none: what reaktor_fade_since starts after. */
|
||||
nk_size
|
||||
reaktor_fade_mark(const struct nk_command_buffer *cv)
|
||||
{
|
||||
return cv->begin == cv->end ? (nk_size)-1 : cv->last;
|
||||
}
|
||||
|
||||
static void
|
||||
fade(struct nk_color *c, float opacity)
|
||||
{
|
||||
c->a = (nk_byte)((float)c->a * opacity + 0.5f);
|
||||
}
|
||||
|
||||
/* Every command drawn since the mark, at the opacity a rule gave it. */
|
||||
void
|
||||
reaktor_fade_since(struct nk_context *ctx, const struct nk_command_buffer *cv,
|
||||
nk_size mark, float opacity)
|
||||
{
|
||||
nk_byte *base = (nk_byte *)ctx->memory.memory.ptr;
|
||||
nk_size at;
|
||||
|
||||
if (cv->begin == cv->end || cv->last == mark) return;
|
||||
at = mark == (nk_size)-1 ? cv->begin
|
||||
: ((const struct nk_command *)(base + mark))->next;
|
||||
for (;;) {
|
||||
struct nk_command *c = (struct nk_command *)(base + at);
|
||||
|
||||
switch (c->type) {
|
||||
case NK_COMMAND_LINE: fade(&((struct nk_command_line *)c)->color, opacity); break;
|
||||
case NK_COMMAND_CURVE: fade(&((struct nk_command_curve *)c)->color, opacity); break;
|
||||
case NK_COMMAND_RECT: fade(&((struct nk_command_rect *)c)->color, opacity); break;
|
||||
case NK_COMMAND_RECT_FILLED:
|
||||
fade(&((struct nk_command_rect_filled *)c)->color, opacity); break;
|
||||
case NK_COMMAND_RECT_MULTI_COLOR: {
|
||||
struct nk_command_rect_multi_color *m = (struct nk_command_rect_multi_color *)c;
|
||||
fade(&m->left, opacity); fade(&m->top, opacity);
|
||||
fade(&m->right, opacity); fade(&m->bottom, opacity);
|
||||
break;
|
||||
}
|
||||
case NK_COMMAND_CIRCLE: fade(&((struct nk_command_circle *)c)->color, opacity); break;
|
||||
case NK_COMMAND_CIRCLE_FILLED:
|
||||
fade(&((struct nk_command_circle_filled *)c)->color, opacity); break;
|
||||
case NK_COMMAND_ARC: fade(&((struct nk_command_arc *)c)->color, opacity); break;
|
||||
case NK_COMMAND_ARC_FILLED:
|
||||
fade(&((struct nk_command_arc_filled *)c)->color, opacity); break;
|
||||
case NK_COMMAND_TRIANGLE:
|
||||
fade(&((struct nk_command_triangle *)c)->color, opacity); break;
|
||||
case NK_COMMAND_TRIANGLE_FILLED:
|
||||
fade(&((struct nk_command_triangle_filled *)c)->color, opacity); break;
|
||||
case NK_COMMAND_POLYGON:
|
||||
fade(&((struct nk_command_polygon *)c)->color, opacity); break;
|
||||
case NK_COMMAND_POLYGON_FILLED:
|
||||
fade(&((struct nk_command_polygon_filled *)c)->color, opacity); break;
|
||||
case NK_COMMAND_POLYLINE:
|
||||
fade(&((struct nk_command_polyline *)c)->color, opacity); break;
|
||||
case NK_COMMAND_TEXT: {
|
||||
struct nk_command_text *t = (struct nk_command_text *)c;
|
||||
fade(&t->background, opacity); fade(&t->foreground, opacity);
|
||||
break;
|
||||
}
|
||||
case NK_COMMAND_IMAGE: fade(&((struct nk_command_image *)c)->col, opacity); break;
|
||||
default: break;
|
||||
}
|
||||
if (at == cv->last) break;
|
||||
at = c->next;
|
||||
}
|
||||
}
|
||||
|
||||
struct nk_rect
|
||||
reaktor_rect_trunc(struct nk_rect b)
|
||||
{
|
||||
|
||||
+1
-15
@@ -1,21 +1,7 @@
|
||||
#ifndef REAKTOR_NK_COMMON_H
|
||||
#define REAKTOR_NK_COMMON_H
|
||||
|
||||
#define NK_INCLUDE_FIXED_TYPES
|
||||
#define NK_INCLUDE_STANDARD_IO
|
||||
#define NK_INCLUDE_STANDARD_VARARGS
|
||||
#define NK_INCLUDE_DEFAULT_ALLOCATOR
|
||||
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
|
||||
#define NK_INCLUDE_COMMAND_USERDATA
|
||||
#define NK_INCLUDE_FONT_BAKING
|
||||
#define NK_INCLUDE_DEFAULT_FONT
|
||||
|
||||
/* A browser delivers press and release in one task. */
|
||||
#define NK_BUTTON_TRIGGER_ON_RELEASE
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../../external/nuklear/nuklear.h"
|
||||
#include "reaktor/nuklear.h"
|
||||
|
||||
/* The caller SDL_frees the ranges. */
|
||||
int reaktor_font_valid(const void *ttf, size_t size);
|
||||
|
||||
+2
-5
@@ -1,6 +1,8 @@
|
||||
#ifndef REAKTOR_TEXT_H
|
||||
#define REAKTOR_TEXT_H
|
||||
|
||||
#include "reaktor/text.h"
|
||||
|
||||
struct nk_context;
|
||||
struct nk_font;
|
||||
struct SDL_Renderer;
|
||||
@@ -9,9 +11,4 @@ void reaktor_text_add_fallback(const char *path);
|
||||
void reaktor_text_attach_font(struct nk_font *font, const char *path);
|
||||
void reaktor_text_prepare(struct nk_context *ctx, struct SDL_Renderer *renderer);
|
||||
|
||||
/* Where the next line starts, at or before limit; 0 if nowhere. */
|
||||
int reaktor_text_break(const char *s, int len, int limit);
|
||||
int reaktor_text_rtl(const char *s, int len);
|
||||
void reaktor_text_describe(char *buf, int cap);
|
||||
|
||||
#endif
|
||||
|
||||
+114
-20
@@ -21,6 +21,7 @@ static float g_ox, g_oy;
|
||||
static struct nk_rect g_boxrect[REAKTOR_LAY_DEPTH + 1];
|
||||
static unsigned char g_boxok[REAKTOR_LAY_DEPTH + 1];
|
||||
static unsigned g_boxid[REAKTOR_LAY_DEPTH + 1];
|
||||
static unsigned char g_boxdir[REAKTOR_LAY_DEPTH + 1];
|
||||
|
||||
void
|
||||
reaktor_frame_begin(App *app, struct nk_context *ctx, struct nk_rect area)
|
||||
@@ -43,6 +44,11 @@ reaktor_frame_end(void)
|
||||
if (g_space) { nk_layout_space_end(g_ctx); g_space = 0; }
|
||||
reaktor_layout_end(&g_app->lay);
|
||||
|
||||
/* This frame's rectangles were laid out with the sizes of an older sheet. */
|
||||
if (g_app->style_gen != reaktor_style_generation()) {
|
||||
g_app->style_gen = reaktor_style_generation();
|
||||
g_unsettled++;
|
||||
}
|
||||
g_app->settled_run = g_unsettled ? 0 : g_app->settled_run + 1;
|
||||
if (!g_unsettled) {
|
||||
g_app->settle_tries = 0;
|
||||
@@ -107,7 +113,10 @@ reaktor_box_open(unsigned char dir, const reaktor_box *b)
|
||||
id = reaktor_note_push(g_app, REAKTOR_A11Y_GROUP, box.name, NULL, 0u,
|
||||
nk_rect(0, 0, 0, 0));
|
||||
reaktor_layout_open(&g_app->lay, id, &box);
|
||||
if (g_depth < REAKTOR_LAY_DEPTH) g_boxid[g_depth + 1] = id;
|
||||
if (g_depth < REAKTOR_LAY_DEPTH) {
|
||||
g_boxid[g_depth + 1] = id;
|
||||
g_boxdir[g_depth + 1] = dir;
|
||||
}
|
||||
|
||||
if (g_widths < (int)(sizeof(g_width) / sizeof(g_width[0]))) {
|
||||
float w = box.w > 0.0f ? box.w : g_width[g_widths - 1];
|
||||
@@ -328,13 +337,65 @@ box_from_style(reaktor_box *box, const char *text, const char *selector,
|
||||
}
|
||||
|
||||
if (st.matched) {
|
||||
if (box->mt <= 0.0f) box->mt = st.margin[REAKTOR_SIDE_TOP];
|
||||
if (box->mr <= 0.0f) box->mr = st.margin[REAKTOR_SIDE_RIGHT];
|
||||
if (box->mb <= 0.0f) box->mb = st.margin[REAKTOR_SIDE_BOTTOM];
|
||||
if (box->ml <= 0.0f) box->ml = st.margin[REAKTOR_SIDE_LEFT];
|
||||
/* A rule's margin parts a widget from its neighbors along its row or
|
||||
* column; across it, the page has sized the box. */
|
||||
unsigned char dir = g_depth > 0 && g_depth <= REAKTOR_LAY_DEPTH
|
||||
? g_boxdir[g_depth] : REAKTOR_LAY_COLUMN;
|
||||
int down = dir != REAKTOR_LAY_ROW, across = dir != REAKTOR_LAY_COLUMN;
|
||||
|
||||
if (box->mt <= 0.0f && down) {
|
||||
box->mt = st.margin[REAKTOR_SIDE_TOP];
|
||||
box->flags |= REAKTOR_LAY_SHEET_T;
|
||||
}
|
||||
if (box->mr <= 0.0f && across) {
|
||||
box->mr = st.margin[REAKTOR_SIDE_RIGHT];
|
||||
box->flags |= REAKTOR_LAY_SHEET_R;
|
||||
}
|
||||
if (box->mb <= 0.0f && down) {
|
||||
box->mb = st.margin[REAKTOR_SIDE_BOTTOM];
|
||||
box->flags |= REAKTOR_LAY_SHEET_B;
|
||||
}
|
||||
if (box->ml <= 0.0f && across) {
|
||||
box->ml = st.margin[REAKTOR_SIDE_LEFT];
|
||||
box->flags |= REAKTOR_LAY_SHEET_L;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fit_button(reaktor_box *box, const reaktor_button_spec *s)
|
||||
{
|
||||
const struct nk_style_button *nb = &g_ctx->style.button;
|
||||
const char *sel = rule_or(s->style, "button");
|
||||
const struct nk_user_font *f = style_font(sel);
|
||||
reaktor_style st;
|
||||
float pad_x, pad_y, border, edge, text = 0.0f, w;
|
||||
|
||||
box->w = box->h = 0.0f;
|
||||
box->flags &= ~(REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y);
|
||||
box_from_style(box, NULL, s->style, "button", nb->padding.x, nb->padding.y);
|
||||
|
||||
reaktor_style_get(sel, &st);
|
||||
pad_x = st.matched ? st.pad_x : nb->padding.x;
|
||||
pad_y = st.matched ? st.pad_y : nb->padding.y;
|
||||
border = st.matched ? st.border : nb->border;
|
||||
edge = border + (st.matched ? st.rounding : nb->rounding);
|
||||
if (s->label)
|
||||
text = f->width(f->userdata, f->height, s->label, (int)strlen(s->label));
|
||||
|
||||
w = text + 2.0f * (pad_x + (st.matched ? border : edge));
|
||||
if (s->icon && s->label) {
|
||||
float room = SDL_max(box->h * 0.5f - edge, 0.0f);
|
||||
float icon = box->h - 2.0f * SDL_min(pad_y, room)
|
||||
- 2.0f * nb->image_padding.x;
|
||||
|
||||
w = SDL_max(w, text + 2.0f * (3.0f * pad_x + nb->image_padding.x + icon));
|
||||
} else if (s->icon) {
|
||||
w = box->h;
|
||||
}
|
||||
box->w = SDL_ceilf(w);
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_gap(float w, float h)
|
||||
{
|
||||
@@ -356,20 +417,41 @@ reaktor_soak(void)
|
||||
(void)place(REAKTOR_A11Y_NONE, NULL, NULL, 0u, NULL, &box, NULL);
|
||||
}
|
||||
|
||||
/* A disabled button wears its sheet's :disabled rule at that rule's opacity;
|
||||
* one the sheet does not tell apart is faded by half. */
|
||||
static float
|
||||
disabled_opacity(const char *sel, const char *dsel)
|
||||
{
|
||||
reaktor_style on, off;
|
||||
|
||||
reaktor_style_get(sel, &on);
|
||||
reaktor_style_get(dsel, &off);
|
||||
if (!off.matched) return 0.5f;
|
||||
if (off.opacity < 1.0f) return off.opacity;
|
||||
return memcmp(on.bg, off.bg, 4) || memcmp(on.fg, off.fg, 4) ||
|
||||
memcmp(on.border_col, off.border_col, 4) ? 1.0f : 0.5f;
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_button(const reaktor_button_spec *s)
|
||||
{
|
||||
reaktor_box box;
|
||||
struct nk_rect r;
|
||||
const char *sel;
|
||||
char dsel[96];
|
||||
unsigned id = 0;
|
||||
int hit, styled, fitted;
|
||||
float fade = 1.0f;
|
||||
nk_size mark = 0;
|
||||
|
||||
if (!g_app || !s) return 0;
|
||||
box = s->box;
|
||||
box_from_style(&box, s->label, s->style, "button",
|
||||
g_ctx->style.button.padding.x,
|
||||
g_ctx->style.button.padding.y);
|
||||
if (s->fit_content)
|
||||
fit_button(&box, s);
|
||||
else
|
||||
box_from_style(&box, s->label, s->style, "button",
|
||||
g_ctx->style.button.padding.x,
|
||||
g_ctx->style.button.padding.y);
|
||||
|
||||
if (!place(REAKTOR_A11Y_BUTTON, s->name ? s->name : s->label, NULL,
|
||||
s->disabled ? REAKTOR_A11Y_DISABLED : 0u, s->keys, &box, &id))
|
||||
@@ -378,9 +460,17 @@ reaktor_button(const reaktor_button_spec *s)
|
||||
r = nk_widget_bounds(g_ctx);
|
||||
|
||||
sel = rule_or(s->style, "button");
|
||||
if (s->disabled) {
|
||||
SDL_snprintf(dsel, sizeof(dsel), "%s.disabled:disabled", sel);
|
||||
fade = disabled_opacity(sel, dsel);
|
||||
sel = dsel;
|
||||
}
|
||||
styled = push_style_font(s->style);
|
||||
if (s->repeat) nk_button_set_behavior(g_ctx, NK_BUTTON_REPEATER);
|
||||
if (s->disabled) nk_widget_disable_begin(g_ctx);
|
||||
if (s->disabled) {
|
||||
nk_widget_disable_begin(g_ctx);
|
||||
mark = reaktor_fade_mark(nk_window_get_canvas(g_ctx));
|
||||
}
|
||||
fitted = reaktor_fit_label(g_app, g_ctx, r);
|
||||
reaktor_note_mute(g_app, 1);
|
||||
if (s->icon && !s->label) {
|
||||
@@ -391,13 +481,17 @@ reaktor_button(const reaktor_button_spec *s)
|
||||
px, s->name);
|
||||
} else if (s->icon)
|
||||
hit = reaktor_button_icon_as(g_app, g_ctx, sel, s->icon, s->label);
|
||||
else if (s->accent)
|
||||
else if (s->accent && !s->disabled)
|
||||
hit = reaktor_button_accent_as(g_app, g_ctx, sel, s->label);
|
||||
else
|
||||
hit = reaktor_button_label_as(g_app, g_ctx, sel, s->label);
|
||||
reaktor_note_mute(g_app, 0);
|
||||
reaktor_unfit_label(g_ctx, fitted);
|
||||
if (s->disabled) nk_widget_disable_end(g_ctx);
|
||||
if (s->disabled) {
|
||||
nk_widget_disable_end(g_ctx);
|
||||
if (fade < 1.0f)
|
||||
reaktor_fade_since(g_ctx, nk_window_get_canvas(g_ctx), mark, fade);
|
||||
}
|
||||
if (s->repeat) nk_button_set_behavior(g_ctx, NK_BUTTON_DEFAULT);
|
||||
if (styled) nk_style_pop_font(g_ctx);
|
||||
|
||||
@@ -581,8 +675,7 @@ reaktor_icon(const reaktor_icon_spec *s)
|
||||
px = (int)box.w;
|
||||
|
||||
im = s->accent
|
||||
? reaktor_ionicon_col(g_app, s->name, px,
|
||||
reaktor_token("--links", g_app->text))
|
||||
? reaktor_ionicon_col(g_app, s->name, px, g_app->accent)
|
||||
: reaktor_ionicon(g_app, s->name, px);
|
||||
|
||||
if (!place(REAKTOR_A11Y_NONE, NULL, NULL, 0u, NULL, &box, NULL)) return;
|
||||
@@ -597,7 +690,8 @@ reaktor_field(const reaktor_field_spec *s)
|
||||
|
||||
if (!g_app || !s || !s->buf || !s->len) return;
|
||||
box = s->box;
|
||||
box_from_style(&box, NULL, s->style, "input", 0.0f, 10.0f);
|
||||
box_from_style(&box, NULL, s->style ? s->style : "input.type-text", "input",
|
||||
0.0f, 10.0f);
|
||||
|
||||
if (!place(REAKTOR_A11Y_TEXTBOX, s->name ? s->name : s->hint,
|
||||
NULL, 0u, NULL, &box, &id))
|
||||
@@ -773,8 +867,7 @@ reaktor_select(const reaktor_select_spec *s)
|
||||
reaktor_select_arm(b, s->on, rs.matched ? rs.rounding
|
||||
: g_ctx->style.selectable.rounding);
|
||||
if (s->icon) {
|
||||
struct nk_color accent = reaktor_token("--links",
|
||||
g_ctx->style.text.color);
|
||||
struct nk_color accent = g_app->accent;
|
||||
struct nk_color ink = *s->on
|
||||
? reaktor_on(accent)
|
||||
: reaktor_token("--text-muted", g_ctx->style.text.color);
|
||||
@@ -903,7 +996,8 @@ reaktor_property(const reaktor_property_spec *s)
|
||||
else SDL_snprintf(text, sizeof(text), "%.2f", now);
|
||||
|
||||
box = s->box;
|
||||
box_from_style(&box, NULL, s->style, "input", 0.0f, 7.0f);
|
||||
box_from_style(&box, NULL, s->style ? s->style : "input.type-text", "input",
|
||||
0.0f, 7.0f);
|
||||
|
||||
if (!place(REAKTOR_A11Y_SPINBUTTON, s->name ? s->name : s->label, text,
|
||||
0u, NULL, &box, &id))
|
||||
@@ -944,7 +1038,7 @@ reaktor_combo_open(const reaktor_combo_spec *s)
|
||||
reaktor_box field;
|
||||
|
||||
memset(&field, 0, sizeof(field));
|
||||
box_from_style(&field, NULL, NULL, "input", 0.0f, 10.0f);
|
||||
box_from_style(&field, NULL, "input.type-text", "input", 0.0f, 10.0f);
|
||||
if (field.h > box.h) box.h = field.h;
|
||||
}
|
||||
|
||||
@@ -1110,11 +1204,11 @@ nav_list(const reaktor_nav_spec *s, int across)
|
||||
nav_look_of(&look[0], item);
|
||||
nav_look_of(&look[1], across ? ".tab-current" : ".sidebar-current");
|
||||
reaktor_style_get(across ? ".tab-edge" : ".sidebar-edge", &edge);
|
||||
list = s->box;
|
||||
reaktor_box_open(across ? REAKTOR_LAY_ROW : REAKTOR_LAY_COLUMN, &list);
|
||||
memset(&down, 0, sizeof(down));
|
||||
down.flags = REAKTOR_LAY_FILL_X;
|
||||
if (!across) box_from_style(&down, NULL, NULL, item, 12.0f, 8.0f);
|
||||
list = s->box;
|
||||
reaktor_box_open(across ? REAKTOR_LAY_ROW : REAKTOR_LAY_COLUMN, &list);
|
||||
id = reaktor_note_push(g_app, list_role[kind], s->name, NULL, 0u,
|
||||
reaktor_box_rect(&r) ? r : nk_rect(0, 0, 0, 0));
|
||||
if (s->list_keys) reaktor_note_keys(g_app, id, s->list_keys);
|
||||
|
||||
+1
-241
@@ -2,6 +2,7 @@
|
||||
#define REAKTOR_DECLARE_H
|
||||
|
||||
#include "layout.h"
|
||||
#include "reaktor/widgets.h"
|
||||
|
||||
#ifndef REAKTOR_APP_FWD
|
||||
#define REAKTOR_APP_FWD
|
||||
@@ -13,245 +14,4 @@ void reaktor_frame_end(void);
|
||||
|
||||
int reaktor_frame_settled(const App *app);
|
||||
|
||||
void reaktor_box_open(unsigned char dir, const reaktor_box *b);
|
||||
void reaktor_box_close(void);
|
||||
|
||||
#define REAKTOR_BOX_SCOPE_(axis, ...) \
|
||||
for (int reaktor_box_scope_ = \
|
||||
(reaktor_box_open((unsigned char)(axis), \
|
||||
&(reaktor_box){ 0, __VA_ARGS__ }), 1); \
|
||||
reaktor_box_scope_; \
|
||||
reaktor_box_scope_ = (reaktor_box_close(), 0))
|
||||
|
||||
int reaktor_box_rect(struct nk_rect *out);
|
||||
|
||||
unsigned reaktor_box_id(void);
|
||||
|
||||
#define REAKTOR_ROW(...) REAKTOR_BOX_SCOPE_(REAKTOR_LAY_ROW, __VA_ARGS__)
|
||||
#define REAKTOR_COLUMN(...) REAKTOR_BOX_SCOPE_(REAKTOR_LAY_COLUMN, __VA_ARGS__)
|
||||
#define REAKTOR_FREE(...) REAKTOR_BOX_SCOPE_(REAKTOR_LAY_FREE, __VA_ARGS__)
|
||||
|
||||
void reaktor_gap(float w, float h);
|
||||
|
||||
void reaktor_soak(void);
|
||||
|
||||
typedef void (*reaktor_action)(void *user);
|
||||
|
||||
typedef struct reaktor_handler {
|
||||
reaktor_action fn;
|
||||
void *user;
|
||||
} reaktor_handler;
|
||||
|
||||
enum { REAKTOR_LEFT = 0, REAKTOR_CENTRE, REAKTOR_RIGHT };
|
||||
|
||||
typedef struct reaktor_button_spec {
|
||||
const char *label;
|
||||
const char *icon;
|
||||
const char *name;
|
||||
const char *style;
|
||||
const char *keys;
|
||||
reaktor_box box;
|
||||
reaktor_handler on_press;
|
||||
unsigned char accent;
|
||||
unsigned char disabled;
|
||||
unsigned char repeat;
|
||||
} reaktor_button_spec;
|
||||
|
||||
int reaktor_button(const reaktor_button_spec *s);
|
||||
|
||||
typedef struct reaktor_label_spec {
|
||||
const char *text;
|
||||
const char *name;
|
||||
const char *value;
|
||||
const char *style;
|
||||
const char *color;
|
||||
reaktor_box box;
|
||||
unsigned char align;
|
||||
unsigned char wrap;
|
||||
unsigned char silent;
|
||||
} reaktor_label_spec;
|
||||
|
||||
void reaktor_label(const reaktor_label_spec *s);
|
||||
|
||||
typedef struct reaktor_swatch_spec {
|
||||
const char *name;
|
||||
struct nk_color fill;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
reaktor_handler on_press;
|
||||
} reaktor_swatch_spec;
|
||||
|
||||
int reaktor_swatch(const reaktor_swatch_spec *s);
|
||||
|
||||
typedef struct reaktor_icon_spec {
|
||||
const char *name;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char accent;
|
||||
} reaktor_icon_spec;
|
||||
|
||||
void reaktor_icon(const reaktor_icon_spec *s);
|
||||
|
||||
typedef struct reaktor_field_spec {
|
||||
char *buf;
|
||||
int *len;
|
||||
int cap;
|
||||
const char *hint;
|
||||
const char *name;
|
||||
const char *style;
|
||||
float pad_x, pad_y;
|
||||
nk_plugin_filter filter;
|
||||
reaktor_box box;
|
||||
unsigned char multiline;
|
||||
} reaktor_field_spec;
|
||||
|
||||
void reaktor_field(const reaktor_field_spec *s);
|
||||
|
||||
typedef struct reaktor_check_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
nk_bool *on;
|
||||
unsigned *flags;
|
||||
unsigned bit;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char box_right;
|
||||
} reaktor_check_spec;
|
||||
|
||||
int reaktor_check(const reaktor_check_spec *s);
|
||||
|
||||
typedef struct reaktor_radio_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
int *choice;
|
||||
int value;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_radio_spec;
|
||||
|
||||
int reaktor_radio(const reaktor_radio_spec *s);
|
||||
|
||||
typedef struct reaktor_select_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
nk_bool *on;
|
||||
const char *icon;
|
||||
unsigned char disc;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char centered;
|
||||
} reaktor_select_spec;
|
||||
|
||||
int reaktor_select(const reaktor_select_spec *s);
|
||||
|
||||
typedef struct reaktor_slider_spec {
|
||||
const char *name;
|
||||
const char *text;
|
||||
float *value;
|
||||
int *ivalue;
|
||||
float lo, hi, step;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_slider_spec;
|
||||
|
||||
void reaktor_slider(const reaktor_slider_spec *s);
|
||||
|
||||
typedef struct reaktor_progress_spec {
|
||||
const char *name;
|
||||
nk_size *value;
|
||||
nk_size max;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char modifiable;
|
||||
} reaktor_progress_spec;
|
||||
|
||||
void reaktor_progress(const reaktor_progress_spec *s);
|
||||
|
||||
typedef struct reaktor_knob_spec {
|
||||
const char *name;
|
||||
float *value;
|
||||
float lo, hi;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_knob_spec;
|
||||
|
||||
void reaktor_knob(const reaktor_knob_spec *s);
|
||||
|
||||
typedef struct reaktor_property_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
int *ivalue;
|
||||
float *fvalue;
|
||||
double *dvalue;
|
||||
double lo, hi, step;
|
||||
float grain;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_property_spec;
|
||||
|
||||
void reaktor_property(const reaktor_property_spec *s);
|
||||
|
||||
typedef struct reaktor_combo_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
float body_h;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char disc;
|
||||
const struct nk_color *swatch;
|
||||
} reaktor_combo_spec;
|
||||
|
||||
int reaktor_combo_open(const reaktor_combo_spec *s);
|
||||
void reaktor_combo_close(void);
|
||||
|
||||
#define REAKTOR_COMBO(...) \
|
||||
for (int reaktor_combo_scope_ = \
|
||||
reaktor_combo_open(&(reaktor_combo_spec){ __VA_ARGS__ }); \
|
||||
reaktor_combo_scope_; \
|
||||
reaktor_combo_scope_ = (reaktor_combo_close(), 0))
|
||||
|
||||
int reaktor_combo_item(const char *label, int chosen);
|
||||
|
||||
typedef struct reaktor_colour_spec {
|
||||
const char *name;
|
||||
struct nk_colorf *value;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_colour_spec;
|
||||
|
||||
void reaktor_colour_pick(const reaktor_colour_spec *s);
|
||||
|
||||
typedef struct reaktor_link_spec {
|
||||
const char *text;
|
||||
const char *name;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
reaktor_handler on_press;
|
||||
unsigned char active;
|
||||
} reaktor_link_spec;
|
||||
|
||||
int reaktor_link(const reaktor_link_spec *s);
|
||||
|
||||
enum { REAKTOR_NAV_PAGES, REAKTOR_NAV_CHOICE, REAKTOR_NAV_ACTIONS };
|
||||
|
||||
typedef struct reaktor_nav_spec {
|
||||
const char *const *items;
|
||||
const char *const *icons;
|
||||
const char *const *keys;
|
||||
int count;
|
||||
int *chosen;
|
||||
const char *name;
|
||||
const char *list_keys;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char kind;
|
||||
unsigned char narrow;
|
||||
} reaktor_nav_spec;
|
||||
|
||||
typedef reaktor_nav_spec reaktor_sidebar_spec;
|
||||
typedef reaktor_nav_spec reaktor_tabs_spec;
|
||||
|
||||
int reaktor_sidebar(const reaktor_sidebar_spec *s);
|
||||
int reaktor_tabs(const reaktor_tabs_spec *s);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -238,6 +238,22 @@ reaktor_focus_activated(App *app, unsigned id)
|
||||
return !held_back(app);
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_focus_area(App *app, struct nk_rect area, unsigned node)
|
||||
{
|
||||
app->body_rect = area;
|
||||
app->page_node = node;
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_focus_scroll(App *app, struct nk_rect *reveal)
|
||||
{
|
||||
if (!app->focus_scroll) return 0;
|
||||
app->focus_scroll = 0;
|
||||
if (reveal) *reveal = app->focus_scroll_rect;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_focus_step(App *app, unsigned id)
|
||||
{
|
||||
|
||||
+3
-27
@@ -1,30 +1,6 @@
|
||||
#ifndef REAKTOR_KEYS_H
|
||||
#define REAKTOR_KEYS_H
|
||||
#ifndef REAKTOR_KEYS_INTERNAL_H
|
||||
#define REAKTOR_KEYS_INTERNAL_H
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
enum {
|
||||
REAKTOR_MOD_SHIFT = 1u << 0,
|
||||
REAKTOR_MOD_CTRL = 1u << 1,
|
||||
REAKTOR_MOD_ALT = 1u << 2,
|
||||
REAKTOR_MOD_CMD = 1u << 3
|
||||
};
|
||||
|
||||
typedef struct reaktor_shortcut {
|
||||
unsigned mods;
|
||||
SDL_Keycode key, key_last;
|
||||
int action;
|
||||
const char *name;
|
||||
} reaktor_shortcut;
|
||||
|
||||
int reaktor_chord(const SDL_Event *e, unsigned mods, SDL_Keycode key);
|
||||
|
||||
int reaktor_shortcut_match(const reaktor_shortcut *table, int count,
|
||||
const SDL_Event *e, int *index);
|
||||
|
||||
int reaktor_chord_text(unsigned mods, SDL_Keycode key, char *out, int cap);
|
||||
|
||||
int reaktor_shortcut_text(const reaktor_shortcut *table, int count,
|
||||
int action, int index, char *out, int cap);
|
||||
#include "reaktor/keys.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -58,6 +58,7 @@ declare(reaktor_layout *l, unsigned id, const reaktor_box *b)
|
||||
if (l->count >= REAKTOR_LAY_MAX) { l->overflow_boxes++; return LAY_INVALID_ID; }
|
||||
|
||||
it = lay_item(&l->ctx);
|
||||
if (it < REAKTOR_LAY_MAX) { l->flags[it] = b->flags; l->dir[it] = b->dir; }
|
||||
lay_set_size_xy(&l->ctx, it, (lay_scalar)b->w, (lay_scalar)b->h);
|
||||
lay_set_contain(&l->ctx, it, contain_of(b));
|
||||
lay_set_behave(&l->ctx, it, behave_of(b));
|
||||
@@ -142,12 +143,51 @@ slot_of(reaktor_layout *l, unsigned id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* A stylesheet's margin only parts a widget from its neighbors. The one
|
||||
* leading a child moves to the end of the child before it, so every wrapped
|
||||
* line starts at the edge, and the last child's trailing one is dropped. */
|
||||
static void
|
||||
part_neighbors(reaktor_layout *l, lay_id box)
|
||||
{
|
||||
lay_id c, prev = LAY_INVALID_ID;
|
||||
int lead, trail;
|
||||
|
||||
if (box >= REAKTOR_LAY_MAX || l->dir[box] == REAKTOR_LAY_FREE) return;
|
||||
lead = l->dir[box] == REAKTOR_LAY_ROW ? 0 : 1;
|
||||
trail = lead + 2;
|
||||
|
||||
for (c = lay_first_child(&l->ctx, box); c != LAY_INVALID_ID;
|
||||
prev = c, c = lay_next_sibling(&l->ctx, c)) {
|
||||
lay_scalar m[4], p[4];
|
||||
|
||||
if (c >= REAKTOR_LAY_MAX || !(l->flags[c] & (REAKTOR_LAY_SHEET_L << lead)))
|
||||
continue;
|
||||
lay_get_margins_ltrb(&l->ctx, c, &m[0], &m[1], &m[2], &m[3]);
|
||||
if (prev != LAY_INVALID_ID) {
|
||||
lay_get_margins_ltrb(&l->ctx, prev, &p[0], &p[1], &p[2], &p[3]);
|
||||
p[trail] += m[lead];
|
||||
lay_set_margins_ltrb(&l->ctx, prev, p[0], p[1], p[2], p[3]);
|
||||
}
|
||||
m[lead] = 0;
|
||||
lay_set_margins_ltrb(&l->ctx, c, m[0], m[1], m[2], m[3]);
|
||||
}
|
||||
if (prev != LAY_INVALID_ID && prev < REAKTOR_LAY_MAX
|
||||
&& (l->flags[prev] & (REAKTOR_LAY_SHEET_L << trail))) {
|
||||
lay_scalar m[4];
|
||||
|
||||
lay_get_margins_ltrb(&l->ctx, prev, &m[0], &m[1], &m[2], &m[3]);
|
||||
m[trail] = 0;
|
||||
lay_set_margins_ltrb(&l->ctx, prev, m[0], m[1], m[2], m[3]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_layout_end(reaktor_layout *l)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!l->started || !l->count) return;
|
||||
for (i = 0; i < l->count; i++) part_neighbors(l, l->item[i]);
|
||||
lay_run_context(&l->ctx);
|
||||
|
||||
l->gen++;
|
||||
|
||||
+10
-27
@@ -3,38 +3,18 @@
|
||||
|
||||
#include "nk_common.h"
|
||||
#include "onlay.h"
|
||||
|
||||
enum {
|
||||
REAKTOR_LAY_ROW = 0,
|
||||
REAKTOR_LAY_COLUMN,
|
||||
REAKTOR_LAY_FREE
|
||||
};
|
||||
|
||||
enum {
|
||||
REAKTOR_LAY_FILL_X = 1u << 0,
|
||||
REAKTOR_LAY_FILL_Y = 1u << 1,
|
||||
REAKTOR_LAY_WRAP = 1u << 2,
|
||||
REAKTOR_LAY_CENTER_X = 1u << 3,
|
||||
REAKTOR_LAY_CENTER_Y = 1u << 4,
|
||||
REAKTOR_LAY_PACK_CENTER = 1u << 5,
|
||||
REAKTOR_LAY_PACK_END = 1u << 6,
|
||||
REAKTOR_LAY_PACK_SPREAD = 1u << 7
|
||||
};
|
||||
|
||||
typedef struct reaktor_box {
|
||||
unsigned char dir;
|
||||
const char *name;
|
||||
float w, h;
|
||||
float weight;
|
||||
float gap;
|
||||
float ml, mt, mr, mb;
|
||||
unsigned flags;
|
||||
} reaktor_box;
|
||||
#include "reaktor/widgets.h"
|
||||
|
||||
#define REAKTOR_LAY_MAX 256
|
||||
#define REAKTOR_LAY_DEPTH 32
|
||||
#define REAKTOR_LAY_SLOTS 512
|
||||
|
||||
/* Sides whose margin a stylesheet set, in Onlay's left, top, right, bottom order. */
|
||||
#define REAKTOR_LAY_SHEET_L (1u << 28)
|
||||
#define REAKTOR_LAY_SHEET_T (1u << 29)
|
||||
#define REAKTOR_LAY_SHEET_R (1u << 30)
|
||||
#define REAKTOR_LAY_SHEET_B (1u << 31)
|
||||
|
||||
typedef struct reaktor_lay_slot {
|
||||
unsigned id;
|
||||
unsigned gen;
|
||||
@@ -49,6 +29,9 @@ typedef struct reaktor_layout {
|
||||
lay_id item[REAKTOR_LAY_MAX];
|
||||
int count;
|
||||
|
||||
unsigned flags[REAKTOR_LAY_MAX];
|
||||
unsigned char dir[REAKTOR_LAY_MAX];
|
||||
|
||||
lay_id stack[REAKTOR_LAY_DEPTH];
|
||||
int depth;
|
||||
|
||||
|
||||
+70
-28
@@ -47,6 +47,8 @@ static struct {
|
||||
const nk_bool *on;
|
||||
struct nk_style_item *slot, saved;
|
||||
float *border, border_was;
|
||||
int edges;
|
||||
struct nk_color edge_hover, edge_active;
|
||||
} g_chrome;
|
||||
|
||||
static void
|
||||
@@ -74,6 +76,7 @@ void
|
||||
reaktor_chrome_disarm(void)
|
||||
{
|
||||
g_chrome.armed = 0;
|
||||
g_chrome.edges = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -94,16 +97,20 @@ button_chrome_begin(struct nk_command_buffer *out, nk_handle user)
|
||||
App *app = (App *)user.ptr;
|
||||
struct nk_style_button *st = &app->ctx->style.button;
|
||||
nk_flags state = app->ctx->last_widget_state;
|
||||
struct nk_color col;
|
||||
struct nk_color col, edge = st->border_color;
|
||||
|
||||
if (!g_chrome.armed ||
|
||||
!chrome_take((state & NK_WIDGET_STATE_HOVER) ? &st->hover
|
||||
: (state & NK_WIDGET_STATE_ACTIVED) ? &st->active
|
||||
: &st->normal, &col))
|
||||
return;
|
||||
/* Nuklear keeps one border color; a rule can give each state its own. */
|
||||
if (g_chrome.edges)
|
||||
edge = (state & NK_WIDGET_STATE_HOVER) ? g_chrome.edge_hover
|
||||
: (state & NK_WIDGET_STATE_ACTIVED) ? g_chrome.edge_active : edge;
|
||||
reaktor_paint_surface(app, out, g_chrome.b, &(reaktor_surface){
|
||||
nk_rgb_factor(col, st->color_factor_background),
|
||||
nk_rgb_factor(st->border_color, st->color_factor_background),
|
||||
nk_rgb_factor(edge, st->color_factor_background),
|
||||
st->border, st->rounding });
|
||||
g_chrome.border = &st->border;
|
||||
g_chrome.border_was = st->border;
|
||||
@@ -173,6 +180,9 @@ push_button_look(App *app, struct nk_context *ctx, const reaktor_button_look *k)
|
||||
nk_style_push_color(ctx, &ctx->style.button.border_color,
|
||||
col_of(s.border_col));
|
||||
f.colors = 4;
|
||||
g_chrome.edges = 1;
|
||||
g_chrome.edge_hover = col_of(hov->matched ? hov->border_col : s.border_col);
|
||||
g_chrome.edge_active = col_of(act->matched ? act->border_col : s.border_col);
|
||||
|
||||
nk_style_push_float(ctx, &ctx->style.button.rounding, s.rounding);
|
||||
nk_style_push_float(ctx, &ctx->style.button.border, s.border);
|
||||
@@ -185,8 +195,9 @@ push_button_look(App *app, struct nk_context *ctx, const reaktor_button_look *k)
|
||||
if (s.pad_y > room) s.pad_y = room;
|
||||
}
|
||||
|
||||
/* Nuklear insets a label by the rounding as well; CSS does not. */
|
||||
nk_style_push_vec2(ctx, &ctx->style.button.padding,
|
||||
nk_vec2(s.pad_x, s.pad_y));
|
||||
nk_vec2(s.pad_x - s.rounding - 0.5f, s.pad_y));
|
||||
f.vec2s = 1;
|
||||
|
||||
if (s.font_px > 0) {
|
||||
@@ -316,7 +327,7 @@ reaktor_visible(struct nk_color want, struct nk_color behind,
|
||||
|
||||
int
|
||||
css_button_accent(App *app, struct nk_context *ctx, const char *selector,
|
||||
const char *label, const char *token)
|
||||
const char *label, struct nk_color accent)
|
||||
{
|
||||
style_frame f, a = { 0, 0, 0, 0, 0 };
|
||||
unsigned char c[4];
|
||||
@@ -327,7 +338,8 @@ css_button_accent(App *app, struct nk_context *ctx, const char *selector,
|
||||
|
||||
f = push_button_style(app, ctx, selector);
|
||||
|
||||
if (reaktor_style_token(token, c)) {
|
||||
c[0] = accent.r; c[1] = accent.g; c[2] = accent.b; c[3] = accent.a;
|
||||
{
|
||||
unsigned char hov[4];
|
||||
memcpy(hov, c, 4);
|
||||
reaktor_style_darken(hov, 0.12f);
|
||||
@@ -340,6 +352,7 @@ css_button_accent(App *app, struct nk_context *ctx, const char *selector,
|
||||
nk_style_item_color(col_of(hov)));
|
||||
a.items = 3;
|
||||
nk_style_push_color(ctx, &ctx->style.button.border_color, col_of(c));
|
||||
g_chrome.edge_hover = g_chrome.edge_active = col_of(c);
|
||||
|
||||
{
|
||||
struct nk_color label_col =
|
||||
@@ -359,20 +372,51 @@ css_button_accent(App *app, struct nk_context *ctx, const char *selector,
|
||||
return clicked;
|
||||
}
|
||||
|
||||
/* Where Nuklear put an icon, left of a label centered across the button. */
|
||||
static int
|
||||
icon_place(struct nk_context *ctx, struct nk_rect b, float pad_x,
|
||||
const char *label, struct nk_rect *at)
|
||||
{
|
||||
const struct nk_style_button *s = &ctx->style.button;
|
||||
const struct nk_user_font *f = ctx->style.font;
|
||||
float text = f->width(f->userdata, f->height, label, (int)SDL_strlen(label));
|
||||
|
||||
at->x = b.x + 2.0f * pad_x + s->image_padding.x;
|
||||
at->y = b.y + s->padding.y + s->image_padding.y;
|
||||
at->w = b.h - 2.0f * s->padding.y - 2.0f * s->image_padding.x;
|
||||
at->h = b.h - 2.0f * s->padding.y - 2.0f * s->image_padding.y;
|
||||
return b.w >= text + 2.0f * (3.0f * pad_x + s->image_padding.x + at->w);
|
||||
}
|
||||
|
||||
int
|
||||
css_button_icon(App *app, struct nk_context *ctx, const char *selector,
|
||||
const char *icon_src, const char *label)
|
||||
{
|
||||
reaktor_button_look k;
|
||||
style_frame f;
|
||||
struct nk_image im = icon(app, icon_src, 18);
|
||||
int clicked;
|
||||
struct nk_rect b = nk_widget_bounds(ctx), at;
|
||||
int clicked, drawn;
|
||||
|
||||
hot_push(app, nk_widget_bounds(ctx), 1, 1);
|
||||
hot_push(app, b, 1, 1);
|
||||
reaktor_note_here(app, ctx, REAKTOR_A11Y_BUTTON, label, 0);
|
||||
f = push_button_style(app, ctx, selector);
|
||||
reaktor_button_look_of(selector, &k);
|
||||
f = push_button_look(app, ctx, &k);
|
||||
drawn = icon_place(ctx, b, k.s.matched ? k.s.pad_x : ctx->style.button.padding.x,
|
||||
label, &at);
|
||||
reaktor_button_arm(ctx);
|
||||
clicked = nk_button_image_label(ctx, im, label, NK_TEXT_CENTERED);
|
||||
clicked = nk_button_label(ctx, label);
|
||||
reaktor_chrome_disarm();
|
||||
if (drawn) {
|
||||
const struct nk_style_button *bs = &ctx->style.button;
|
||||
nk_flags state = ctx->last_widget_state;
|
||||
struct nk_image im = icon(app, icon_src, 18);
|
||||
struct nk_color ink = (state & NK_WIDGET_STATE_HOVER) ? bs->text_hover
|
||||
: (state & NK_WIDGET_STATE_ACTIVED) ? bs->text_active
|
||||
: bs->text_normal;
|
||||
|
||||
nk_draw_image(nk_window_get_canvas(ctx), at, &im,
|
||||
nk_rgb_factor(ink, bs->color_factor_text));
|
||||
}
|
||||
pop_style(ctx, f);
|
||||
return clicked;
|
||||
}
|
||||
@@ -433,8 +477,8 @@ push_edit_style(struct nk_context *ctx, reaktor_style *out, int inset)
|
||||
style_frame f = { 0, 0, 0, 0, 0 };
|
||||
unsigned char body[4];
|
||||
|
||||
reaktor_style_get("input", &s);
|
||||
reaktor_style_get("input:focus", &foc);
|
||||
reaktor_style_get("input.type-text", &s);
|
||||
reaktor_style_get("input.type-text:focus", &foc);
|
||||
reaktor_style_get("button", &btn);
|
||||
if (btn.matched) s.rounding = btn.rounding;
|
||||
s.pad_x += s.border;
|
||||
@@ -674,26 +718,26 @@ apply_widget_style(App *app)
|
||||
struct nk_color on_accent, thumb, thumb_hi;
|
||||
struct nk_style_item i_none, i_base, i_hover, i_accent;
|
||||
reaktor_style btn, btn_hov, inp, sel, det, sum, dlg;
|
||||
reaktor_style rng, acc;
|
||||
reaktor_style rng;
|
||||
unsigned char c[4], ac[4];
|
||||
|
||||
if (!app->ctx) return;
|
||||
ctx = app->ctx;
|
||||
st = &ctx->style;
|
||||
|
||||
body = reaktor_token("--background-body", app->page);
|
||||
body = app->page;
|
||||
base = reaktor_token("--background", app->card_bg);
|
||||
hover = reaktor_token("--background-hover", base);
|
||||
text = reaktor_token("--text-main", app->text);
|
||||
text = app->text;
|
||||
muted = reaktor_token("--text-muted", text);
|
||||
bright = reaktor_token("--text-bright", text);
|
||||
accent = reaktor_token("--links", text);
|
||||
accent = app->accent;
|
||||
focus = reaktor_token("--focus", accent);
|
||||
|
||||
edge = hover;
|
||||
|
||||
on_accent = reaktor_style_token("--links", ac)
|
||||
? readable_on(ac, "--text-bright", "--background-body") : bright;
|
||||
ac[0] = accent.r; ac[1] = accent.g; ac[2] = accent.b; ac[3] = accent.a;
|
||||
on_accent = readable_on(ac, "--text-bright", "--background-body");
|
||||
|
||||
thumb = nk_rgba(muted.r, muted.g, muted.b, 110);
|
||||
thumb_hi = nk_rgba(muted.r, muted.g, muted.b, 175);
|
||||
@@ -728,8 +772,10 @@ apply_widget_style(App *app)
|
||||
st->button.userdata = nk_handle_ptr(app);
|
||||
st->button.draw_begin = button_chrome_begin;
|
||||
st->button.draw_end = chrome_end;
|
||||
/* A disabled button is faded, not darkened: see reaktor_button. */
|
||||
st->button.disabled_factor = 1.0f;
|
||||
|
||||
reaktor_style_get("input", &inp);
|
||||
reaktor_style_get("input.type-text", &inp);
|
||||
if (inp.matched) {
|
||||
struct nk_color sel_text = reaktor_style_token("--focus", c)
|
||||
? readable_on(c, "--text-bright",
|
||||
@@ -774,7 +820,6 @@ apply_widget_style(App *app)
|
||||
st->selectable.image_padding = nk_vec2(7.0f, 7.0f);
|
||||
|
||||
reaktor_style_get("input", &rng);
|
||||
reaktor_style_get("a", &acc);
|
||||
|
||||
st->slider.normal = i_none;
|
||||
st->slider.hover = i_none;
|
||||
@@ -782,9 +827,8 @@ apply_widget_style(App *app)
|
||||
st->slider.bar_normal = rng.matched ? col_of(rng.bg) : edge;
|
||||
st->slider.bar_hover = st->slider.bar_normal;
|
||||
st->slider.bar_active = st->slider.bar_normal;
|
||||
st->slider.bar_filled = acc.matched ? col_of(acc.fg) : accent;
|
||||
st->slider.cursor_normal = acc.matched
|
||||
? nk_style_item_color(col_of(acc.fg)) : i_accent;
|
||||
st->slider.bar_filled = accent;
|
||||
st->slider.cursor_normal = i_accent;
|
||||
st->slider.cursor_hover = nk_style_item_color(focus);
|
||||
st->slider.cursor_active = nk_style_item_color(focus);
|
||||
st->slider.border_color = rng.matched ? col_of(rng.border_col) : edge;
|
||||
@@ -802,7 +846,7 @@ apply_widget_style(App *app)
|
||||
st->knob.knob_hover = hover;
|
||||
st->knob.knob_active = hover;
|
||||
st->knob.knob_border_color = btn.matched ? col_of(btn.border_col) : edge;
|
||||
st->knob.cursor_normal = acc.matched ? col_of(acc.fg) : accent;
|
||||
st->knob.cursor_normal = accent;
|
||||
st->knob.cursor_hover = focus;
|
||||
st->knob.cursor_active = focus;
|
||||
st->knob.border_color = btn.matched ? col_of(btn.border_col) : edge;
|
||||
@@ -812,14 +856,12 @@ apply_widget_style(App *app)
|
||||
: i_base;
|
||||
st->progress.hover = st->progress.normal;
|
||||
st->progress.active = st->progress.normal;
|
||||
st->progress.cursor_normal = acc.matched
|
||||
? nk_style_item_color(col_of(acc.fg))
|
||||
: i_accent;
|
||||
st->progress.cursor_normal = i_accent;
|
||||
st->progress.cursor_hover = nk_style_item_color(focus);
|
||||
st->progress.cursor_active = nk_style_item_color(focus);
|
||||
st->progress.border_color = rng.matched ? col_of(rng.border_col)
|
||||
: edge;
|
||||
st->progress.cursor_border_color = acc.matched ? col_of(acc.fg) : accent;
|
||||
st->progress.cursor_border_color = accent;
|
||||
st->progress.border = 0.0f;
|
||||
st->progress.cursor_border = 0.0f;
|
||||
{
|
||||
|
||||
+14
-8
@@ -133,7 +133,7 @@ reaktor_link_label(App *app, struct nk_context *ctx, const char *label, int acti
|
||||
clicked = 1;
|
||||
}
|
||||
|
||||
col = active ? reaktor_token("--links", app->text)
|
||||
col = active ? app->accent
|
||||
: reaktor_token("--text-muted", app->text);
|
||||
|
||||
nk_style_push_color(ctx, &ctx->style.text.color, col);
|
||||
@@ -497,7 +497,7 @@ int
|
||||
reaktor_button_accent_as(App *app, struct nk_context *ctx, const char *sel,
|
||||
const char *label)
|
||||
{
|
||||
return css_button_accent(app, ctx, sel, label, "--links");
|
||||
return css_button_accent(app, ctx, sel, label, app->accent);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -507,15 +507,14 @@ reaktor_button_icon_as(App *app, struct nk_context *ctx, const char *sel,
|
||||
char src[192];
|
||||
|
||||
SDL_snprintf(src, sizeof(src),
|
||||
"external/ionicons/src/svg/%s.svg?stroke=%s",
|
||||
ionicon, app->icon_hex);
|
||||
"external/ionicons/src/svg/%s.svg?stroke=#ffffff", ionicon);
|
||||
return css_button_icon(app, ctx, sel, src, label);
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_button_accent(App *app, struct nk_context *ctx, const char *label)
|
||||
{
|
||||
return css_button_accent(app, ctx, "button", label, "--links");
|
||||
return css_button_accent(app, ctx, "button", label, app->accent);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -579,8 +578,7 @@ reaktor_button_icon(App *app, struct nk_context *ctx, const char *ionicon,
|
||||
char src[192];
|
||||
|
||||
SDL_snprintf(src, sizeof(src),
|
||||
"external/ionicons/src/svg/%s.svg?stroke=%s",
|
||||
ionicon, app->icon_hex);
|
||||
"external/ionicons/src/svg/%s.svg?stroke=#ffffff", ionicon);
|
||||
return css_button_icon(app, ctx, "button", src, label);
|
||||
}
|
||||
|
||||
@@ -1157,6 +1155,14 @@ reaktor_menu_item(App *app, struct nk_context *ctx, const char *label,
|
||||
}
|
||||
return hit;
|
||||
}
|
||||
void
|
||||
reaktor_frame_ms(App *app, double *build, double *render, double *present)
|
||||
{
|
||||
if (build) *build = app->build_ms_x100 / 100.0;
|
||||
if (render) *render = app->render_ms_x100 / 100.0;
|
||||
if (present) *present = app->present_ms_x100 / 100.0;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_diagnostics(App *app, reaktor_diag *out)
|
||||
{
|
||||
@@ -1213,7 +1219,7 @@ reaktor_diagnostics(App *app, reaktor_diag *out)
|
||||
out->atlas_bpp = app->atlas_bpp;
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < RSS_STEPS; i++) {
|
||||
for (i = 0; i < REAKTOR_RSS_STEPS; i++) {
|
||||
out->rss_at[i] = (unsigned long)reaktor_rss[i];
|
||||
out->priv_at[i] = (unsigned long)reaktor_priv[i];
|
||||
}
|
||||
|
||||
+5
-2
@@ -40,8 +40,11 @@ what the library draws, and where its claims are tested rather than asserted:
|
||||
and can have the showcase ask before it closes.
|
||||
- **Diagnostics** shows the renderer, and where each frame's milliseconds and
|
||||
each megabyte went, live.
|
||||
- **Animation** draws all 31 easing curves through the function the widgets
|
||||
animate with.
|
||||
- **Animation** sends five blocks to one stop, one of them instantly, draws
|
||||
all 31 easing curves through the function the widgets animate with, and
|
||||
plays the rest of NukAnim: a clip staggered across a grid under its debug
|
||||
timeline, motion along paths, oscillators, noise and a shake, one blend in
|
||||
five color spaces, and text arriving a glyph at a time.
|
||||
|
||||
## Notepad
|
||||
|
||||
|
||||
+162
-37
@@ -19,7 +19,7 @@
|
||||
web it returns at once, and a second call returns 1.
|
||||
|
||||
```c
|
||||
#include "reaktor/launch.h"
|
||||
#include "reaktor/reaktor.h"
|
||||
#include "reaktor/main.h" /* in the one file that defines main */
|
||||
|
||||
int
|
||||
@@ -39,6 +39,14 @@ keys mean. Only `.page` is required. `launchApp` is an inline alias of
|
||||
`reaktor_launch_app`, left out under `REAKTOR_NO_SHORT_NAMES`.
|
||||
[`samples/simple/simple.c`](../samples/simple/simple.c) is a whole application.
|
||||
|
||||
`reaktor/reaktor.h` is the whole public API: it includes the rest of
|
||||
[`include/reaktor/`](../include/reaktor/) — Nuklear as Reaktor configures it,
|
||||
`launch.h`, `widgets.h`, `keys.h`, `a11y.h`, `ui.h`, `anim.h`, `locale.h`,
|
||||
`style.h` and `text.h` — and nothing from `src/` or `core/`. `App` is opaque:
|
||||
the calls below ask it what an application may know. Every sample includes
|
||||
only these headers, and MSVC builds an app with implicit declarations as
|
||||
errors, so an internal function cannot slip back in.
|
||||
|
||||
| Hook | When |
|
||||
| --- | --- |
|
||||
| `page(app, ctx, w, h)` | Every frame, inside a panel covering the window |
|
||||
@@ -59,6 +67,11 @@ keys mean. Only `.page` is required. `launchApp` is an inline alias of
|
||||
| `reaktor_set_confirm_close(app, question)` | Ask `question` before quitting, or with `NULL` stop asking |
|
||||
| `reaktor_file_open(app)` | Show the platform's file picker; the answer goes to `file_opened` |
|
||||
| `reaktor_user(app)` | The launch's `.user` |
|
||||
| `reaktor_sdl_window(app)`, `reaktor_sdl_renderer(app)` | That App's SDL window and renderer |
|
||||
| `reaktor_icon_surface(name, px)` | An SVG asset as an `SDL_Surface`, for a tray or icon of the app's own |
|
||||
| `reaktor_dark(app)`, `reaktor_get_theme(app)` | Whether it draws dark; the scheme chosen |
|
||||
| `reaktor_lang_pref(app)` | The language `--lang` asked for, or `NULL` |
|
||||
| `reaktor_set_borderless(app, on)`, `reaktor_borderless(app)` | Switch the main window's frame off for a titlebar of your own, drawn with `.window.hit_test` |
|
||||
|
||||
The `set` calls are for the main thread, take effect at the next frame, and do
|
||||
nothing when nothing changes.
|
||||
@@ -102,11 +115,11 @@ if (reaktor_button(&(reaktor_button_spec){
|
||||
Every spec has `.name` (the accessible name, and how layout finds the widget
|
||||
again), `.style` (a selector to read instead of the widget's own) and `.box`
|
||||
([Layout](#layout)). They are declared in
|
||||
[`core/ui/declare.h`](../core/ui/declare.h).
|
||||
[`include/reaktor/widgets.h`](../include/reaktor/widgets.h).
|
||||
|
||||
| Widget | Call | Answers 1 | Its own fields |
|
||||
| --- | --- | --- | --- |
|
||||
| Button | `reaktor_button` | when pressed | `.label`, `.icon`, `.accent`, `.disabled`, `.repeat` (fires while held), `.keys`, `.on_press` |
|
||||
| Button | `reaktor_button` | when pressed | `.label`, `.icon`, `.accent`, `.disabled`, `.repeat` (fires while held), `.keys`, `.on_press`, `.fit_content` (exactly as large as its label and icon, whatever `.box` asks) |
|
||||
| Link | `reaktor_link` | when pressed | `.text`, `.active`, `.on_press` |
|
||||
| Label | `reaktor_label` | — | `.text`, `.wrap`, `.align` (`REAKTOR_LEFT`, `_CENTRE`, `_RIGHT`), `.color` (a token), `.value`, `.silent` (left out of the tree) |
|
||||
| Icon | `reaktor_icon` | — | `.name` (an Ionicon), `.accent` |
|
||||
@@ -124,6 +137,9 @@ again), `.style` (a selector to read instead of the widget's own) and `.box`
|
||||
| Sidebar | `reaktor_sidebar` | when an entry is chosen | [below](#sidebar-and-tabs) |
|
||||
| Tabs | `reaktor_tabs` | when an entry is chosen | [below](#sidebar-and-tabs) |
|
||||
|
||||
**An icon gives way to its label**: a button too narrow for both draws the
|
||||
label alone. `.fit_content` makes it as large as both need.
|
||||
|
||||
**A field writes back** its bytes into `.buf` and its length into `*.len`, and
|
||||
reads both next frame, so the length must be the field's own: one from
|
||||
anywhere else reseeds the buffer. Ctrl+Z and Ctrl+R undo and redo from a
|
||||
@@ -214,15 +230,16 @@ wrap it in `REAKTOR_FREE` to inset it.
|
||||
before computed, found by accessibility id, and a box seen for the first time
|
||||
waits a frame. So a size that depends on content takes a frame to settle, and
|
||||
a widget whose text changes every frame needs a stable `.name` or it never has
|
||||
a rectangle. After sixteen unsettled frames the runtime stops redrawing and
|
||||
logs the box.
|
||||
a rectangle. The first frame after the stylesheets load counts as unsettled
|
||||
too, since its rectangles were laid out with the old sheet's sizes. After
|
||||
sixteen unsettled frames the runtime stops redrawing and logs the box.
|
||||
|
||||
## Layers
|
||||
|
||||
Above the page, inside the main window: floaters, then toasts. Windows and
|
||||
the tray are the system's. Their specs are in
|
||||
[`include/reaktor/launch.h`](../include/reaktor/launch.h), except the toast's,
|
||||
in [`src/ui.h`](../src/ui.h); all of them are main-thread calls.
|
||||
in [`include/reaktor/ui.h`](../include/reaktor/ui.h); all of them are main-thread calls.
|
||||
|
||||
### Floaters
|
||||
|
||||
@@ -340,9 +357,10 @@ if (s.matched) { /* s.bg, s.fg, s.border, s.rounding, s.pad[4], s.font_px */ }
|
||||
|
||||
| Widget | Reads |
|
||||
| --- | --- |
|
||||
| Button | `button`; an accent one fills with `--links` |
|
||||
| Button | `button`; an accent one fills with the accent, a disabled one reads `button.disabled:disabled` |
|
||||
| Link | `a` |
|
||||
| Field, check, radio, property | `input` |
|
||||
| Field, property | `input.type-text`: a sheet's `input` rule and its `[type=text]` one |
|
||||
| Check, radio | `input` |
|
||||
| Slider | `input.type-range` |
|
||||
| Progress | `progress` |
|
||||
| Select, combo | `select` |
|
||||
@@ -350,21 +368,43 @@ if (s.matched) { /* s.bg, s.fg, s.border, s.rounding, s.pad[4], s.font_px */ }
|
||||
| Toast | `.toast`, `.toast-button`, `.toast-close` |
|
||||
| Sidebar, tabs | `.sidebar-item`, `.sidebar-current`, `.sidebar-edge`; `.tab`, `.tab-current`, `.tab-edge` |
|
||||
|
||||
With `:hover` and `:active` where a widget has those states. Controls a
|
||||
document lacks borrow from what they resemble: a slider's rail from `input`,
|
||||
the accent from `a`, a knob's body from `button` — reading the accent off `a`
|
||||
rather than a token is what lets a sheet that never declares `--links` work.
|
||||
With `:hover` and `:active` where a widget has those states, a button's
|
||||
border included. Controls a document lacks borrow from what they resemble: a
|
||||
slider's rail from `input`, the accent from `a:link` (which a plain `a` rule
|
||||
answers too), a knob's body from `button` — reading the accent off the link
|
||||
rule rather than a token is what lets a sheet that never declares `--links`
|
||||
work, and it fills accent buttons, sliders, progress, checks and the accent
|
||||
icons. The page and the text on it come from `body` the same way, and
|
||||
`reaktor_page_color` and `reaktor_accent_color` hand an application the page
|
||||
and the accent. An icon on a button takes its label's color.
|
||||
|
||||
- **A size set in code beats the sheet.** A `.box = { .h = N }` locks CSS out of
|
||||
that axis, the usual reason a rule "only changes the color".
|
||||
- **A disabled button wears the sheet's own rule.** It reads
|
||||
`button.disabled:disabled`, so `button:disabled` and `button[disabled]` both
|
||||
count, and that rule's `opacity` fades everything the button draws, as a
|
||||
browser fades it. A sheet that does not tell a disabled button apart gets
|
||||
half. Nuklear's own dimming, which multiplies colors toward black, is off.
|
||||
- **A rule's margin only parts a widget from its neighbors.** Across its row
|
||||
or column the page has sized the box, so in a row a rule's top and bottom
|
||||
margins are skipped, and in a column its left and right ones. Along it the
|
||||
margins go between widgets, never before the first or after the last, so a
|
||||
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, keeps the
|
||||
`@media (prefers-color-scheme)` branch for the active scheme and drops width
|
||||
and print queries, and rewrites `[type=range]` as `.type-range`. An operator
|
||||
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 the `@media (prefers-color-scheme)` branch for the active scheme 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. Sheets are read in the C
|
||||
locale's numbers whatever the program's locale.
|
||||
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`.
|
||||
|
||||
@@ -386,7 +426,7 @@ test that the look is not in the code.
|
||||
A field keeps the arrows, Home, End, Enter and Space while it is edited; Tab
|
||||
leaves it. A modal floater or an open popup keeps focus inside. A spec's
|
||||
`.keys` only announces a shortcut; bind it in the `key` hook.
|
||||
[`core/ui/keys.h`](../core/ui/keys.h) matches events against a table of
|
||||
[`include/reaktor/keys.h`](../include/reaktor/keys.h) matches events against a table of
|
||||
shortcuts (`reaktor_shortcut_match`) and writes the same table as text for
|
||||
`.keys` (`reaktor_shortcut_text`), so the two never disagree.
|
||||
|
||||
@@ -406,7 +446,8 @@ The tree is still built, because layout and animation key on its ids.
|
||||
|
||||
## Animation
|
||||
|
||||
A number that takes time to change, keyed by a box's id.
|
||||
[NukAnim](https://github.com/Alpaq92/NukAnim), in `external/nukanim`, runs it.
|
||||
The simplest of it is a number that takes time to change, keyed by a box's id.
|
||||
|
||||
```c
|
||||
REAKTOR_COLUMN(.name = "Track", .h = 56.0f) {
|
||||
@@ -421,8 +462,26 @@ The first call starts at its target: nothing has changed yet. A new target
|
||||
starts a run from wherever the value is, so a change mid-flight redirects
|
||||
rather than restarts. `channel`, the second argument, tells several numbers on
|
||||
one box apart, and each window keeps its own. There are 31 curves, and `reaktor_ease_at(curve, t)` draws
|
||||
them. An entry dies with its node, and a page with nothing moving asks for no
|
||||
frames.
|
||||
them; `reaktor_anim_progress` says how far a run has got.
|
||||
|
||||
The rest of `nukanim.h` works on the window's context, `reaktor_anim(app)`:
|
||||
springs, steps and béziers, colors blended in OKLAB, clips and timelines,
|
||||
motion paths, oscillators and noise, and ImAnimate's way of animating a value
|
||||
that keeps its own state:
|
||||
|
||||
```c
|
||||
if (hovered) nka_animate(reaktor_anim(app), 1.0f, 1.1f, 150.0f, &size, NKA_EASE_OUT_CUBIC);
|
||||
else nka_animate(reaktor_anim(app), 1.1f, 1.0f, 250.0f, &size, NKA_EASE_OUT_CUBIC);
|
||||
```
|
||||
|
||||
The runtime moves the context's time before each page and draws another frame
|
||||
while anything the page sampled is still moving, so a page with nothing moving
|
||||
asks for no frames. What is not sampled for 600 frames is forgotten. Something
|
||||
that changes under the pointer needs a hot rectangle, `reaktor_hot`, for the
|
||||
pointer's motion to run a frame. NukAnim's debug timeline,
|
||||
`nka_show_debug_timeline`, lays out a row of its own, so it goes between
|
||||
declared blocks rather than inside one, and its tooltips follow the pointer
|
||||
only across a `reaktor_hot_follow` rectangle.
|
||||
|
||||
## Beyond the specs
|
||||
|
||||
@@ -430,23 +489,27 @@ Nuklear is still there. Groups, trees, list views, charts, menus and popup
|
||||
bodies have no spec, and the samples call `nk_*` for them. A declared tree and
|
||||
`nk_layout_row_*` cannot share a panel, so convert a whole container at a
|
||||
time; a group or popup is its own panel and may be laid out by hand inside a
|
||||
declared page. [`src/ui.h`](../src/ui.h) has the pieces the specs are made of:
|
||||
declared page. [`include/reaktor/ui.h`](../include/reaktor/ui.h) has the pieces the specs are made of:
|
||||
|
||||
| Helper | For |
|
||||
| --- | --- |
|
||||
| `reaktor_token`, `reaktor_col`, `reaktor_on`, `reaktor_visible` | Colors from the sheet; readable text on a background |
|
||||
| `reaktor_token`, `reaktor_col`, `reaktor_on`, `reaktor_visible`, `reaktor_page_color`, `reaktor_accent_color` | Colors from the sheet; readable text on a background; the page and the accent |
|
||||
| `reaktor_font`, `reaktor_style_font` | A baked face, by size or by selector |
|
||||
| `reaktor_ionicon` | An Ionicon as an `nk_image` |
|
||||
| `reaktor_ionicon`, `reaktor_ionicon_exact`, `reaktor_glyph_at` | An Ionicon as an `nk_image`, in any color, or drawn into a rectangle |
|
||||
| `reaktor_svg`, `REAKTOR_MARK` | Any SVG asset, recolored by `?stroke=#rrggbb&fill=&sw=`; the mark's name |
|
||||
| `reaktor_fill_round`, `reaktor_edge_round` | Rounded fills and borders, smooth on the software renderer |
|
||||
| `reaktor_hot`, `reaktor_hot_top`, `reaktor_hot_follow` | A rectangle that redraws on hover ([the frame loop](#the-frame-loop)) |
|
||||
| `reaktor_button_label`, `reaktor_button_accent`, `reaktor_slider_bar`, `reaktor_progress_bar`, `reaktor_chevron_at` | Styled controls inside `nk_` layouts |
|
||||
| `reaktor_button_label`, `reaktor_button_icon`, `reaktor_button_accent`, `reaktor_field_text`, `reaktor_slider_bar`, `reaktor_progress_bar`, `reaktor_chevron_at` | Styled controls inside `nk_` layouts |
|
||||
| `reaktor_menu_item`, `reaktor_menu_style_push`, `_pop`, `reaktor_menu_height`, `reaktor_menu_edge`, `reaktor_popup_rounding` | Menus and popups |
|
||||
| `reaktor_note`, `_push`, `_pop`, `_here`, `_keys`, `_value`, `_bounds`, `reaktor_focus_activated` | The accessibility tree, and keyboard presses |
|
||||
| `reaktor_diagnostics` | What the Diagnostics page shows |
|
||||
| `reaktor_focus_area`, `reaktor_focus_scroll` | A scrolling page body: the area and node focus moves within, and the rectangle it asks to see |
|
||||
| `reaktor_diagnostics`, `reaktor_frame_ms` | What the Diagnostics page shows; one frame's build, render and present |
|
||||
| `reaktor_process_memory`, `reaktor_process_cpu_ms` | The process's resident and private bytes, and its CPU time |
|
||||
|
||||
The rest is by subject: [`keys.h`](../core/ui/keys.h),
|
||||
[`anim.h`](../core/anim/anim.h), [`locale.h`](../core/locale/locale.h),
|
||||
[`text.h`](../core/text/text.h) and [`style.h`](../core/css/style.h).
|
||||
The rest is by subject: [`keys.h`](../include/reaktor/keys.h),
|
||||
[`anim.h`](../include/reaktor/anim.h), [`locale.h`](../include/reaktor/locale.h),
|
||||
[`text.h`](../include/reaktor/text.h), [`style.h`](../include/reaktor/style.h)
|
||||
and [`a11y.h`](../include/reaktor/a11y.h).
|
||||
|
||||
---
|
||||
|
||||
@@ -477,7 +540,7 @@ core/css cssflat and the libcss front end
|
||||
core/render Nuklear, the SDL3 backend, drawing, SVG icons
|
||||
core/ui specs, layout, widgets, the style map, keys, focus, floaters, toasts
|
||||
core/a11y the shadow tree and its diff
|
||||
core/anim eased values
|
||||
core/anim NukAnim, a context a window
|
||||
core/locale the Locale module
|
||||
core/text the Text module
|
||||
platform/ theme, process lifecycle, the accessibility bridges, the web keyboard
|
||||
@@ -485,7 +548,7 @@ runtime/ the main window and its loop, other windows, the tray
|
||||
samples/ showcase, notepad, simple, bench
|
||||
tools/ the tests, the icon compiler, vmwalk
|
||||
benchmarks/ bench in four other frameworks, and the sampler
|
||||
external/ ten submodules, read as they ship
|
||||
external/ eleven submodules, read as they ship
|
||||
```
|
||||
|
||||
`runtime/` and `core/` build `reaktor_runtime`, a static library every
|
||||
@@ -520,6 +583,13 @@ While a mouse button is held, frames follow the display's refresh, with two
|
||||
more after the release. A turn of the wheel takes two frames, because Nuklear
|
||||
scrolls a panel after drawing it.
|
||||
|
||||
A finger that moves mostly up or down, by more than 8 pixels, scrolls the
|
||||
panel under it: the runtime releases what the finger pressed away from every
|
||||
widget, so nothing is clicked, and turns its movement into wheel steps sized
|
||||
to the page body `reaktor_focus_area` names, or to the window. A fast swipe
|
||||
coasts on after the finger lifts, and a touch stops it. Sideways drags, and
|
||||
drags that start in a text field, stay drags.
|
||||
|
||||
Nuklear reads input as it stands at a frame's end: a button pressed and
|
||||
released within one frame was never down. So a frame takes one change — a
|
||||
button or a key — or a run of text, and faster input is spread over the frames
|
||||
@@ -560,8 +630,9 @@ ARM64 build tools.
|
||||
**Releases.** Pushing a `v*` tag runs `release.yml`: the four native
|
||||
workflows again, with every job required, a web build, and a GitHub release
|
||||
of what they packed — one archive per system and architecture, the three
|
||||
WebAssembly programs, and the source with its submodules, which GitHub's own
|
||||
archives leave out. `tools/package.sh <build> <folder> [.exe]` packs a native
|
||||
WebAssembly programs, libreaktor for each ([In your own project](#in-your-own-project)),
|
||||
the source with its submodules, which GitHub's own archives leave out, and a
|
||||
`SHA256SUMS` of them all. `tools/package.sh <build> <folder> [.exe]` packs a native
|
||||
one: the four programs without their symbols, the `.reaktor-root` marker, the
|
||||
files they read at runtime (`tools/assets.sh`, which the macOS app bundle uses
|
||||
too), `licenses/` and `NOTICE.md`. Each job runs the packed showcase and
|
||||
@@ -570,6 +641,54 @@ C runtime statically (`-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded`); the macOS
|
||||
app is signed ad hoc, not notarized; Linux needs glibc 2.36, or 2.41 on
|
||||
RISC-V; a BSD package wants the release it was built on.
|
||||
|
||||
## In your own project
|
||||
|
||||
**Embedded.** Add the checkout, submodules and all, and declare the app:
|
||||
|
||||
```cmake
|
||||
add_subdirectory(reaktor) # or FetchContent, which clones the submodules too
|
||||
reaktor_add_app(myapp SOURCES main.c)
|
||||
```
|
||||
|
||||
Under another project Reaktor builds none of its samples or tests and
|
||||
installs nothing (`REAKTOR_SAMPLES`, `REAKTOR_TESTS` and `REAKTOR_INSTALL`
|
||||
default to on only at the top), and its settings stay in its own directory.
|
||||
A module's sources compile in the app's directory, so the one that needs a
|
||||
language of its own, the macOS accessibility bridge in Objective-C, is
|
||||
compiled in Reaktor's instead: the app needs no Objective-C, and no ARC flag.
|
||||
[`examples/embedded`](../examples/embedded) declares Simple this way from a
|
||||
directory of its own; the macOS jobs and Linux x86-64 build it and check it
|
||||
draws as the in-tree build does.
|
||||
|
||||
**libreaktor.** Each release carries `libreaktor-<version>-<system>-<arch>`
|
||||
for every platform above, and `-wasm`. Build one yourself with:
|
||||
|
||||
```bash
|
||||
cmake --build build --target libreaktor
|
||||
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,
|
||||
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`:
|
||||
|
||||
```cmake
|
||||
find_package(reaktor 0.4 REQUIRED)
|
||||
add_executable(app WIN32 main.c)
|
||||
target_link_libraries(app PRIVATE reaktor::reaktor)
|
||||
```
|
||||
|
||||
`pkg-config --cflags --libs reaktor` answers the same outside CMake. The
|
||||
library takes the C runtime its build used: the release's Windows ones use
|
||||
the DLL runtime, CMake's default, while the programs in a release link it
|
||||
statically. On the web, point `reaktor_DIR` at its `lib/cmake/reaktor`, as
|
||||
the emscripten toolchain searches only its own sysroot.
|
||||
[`examples/consumer`](../examples/consumer) builds `samples/simple/simple.c`
|
||||
against an installed package: every CI job does, and checks it draws as the
|
||||
in-tree build does.
|
||||
|
||||
## Build options
|
||||
|
||||
Passed to CMake, through either script:
|
||||
@@ -586,6 +705,8 @@ Passed to CMake, through either script:
|
||||
| `REAKTOR_LOCALE_EMBED` | `OFF` | Compile the catalogs in rather than read them at startup |
|
||||
| `REAKTOR_TEXT` | `ON` | Direction, shaping, fallback glyphs and Unicode line breaks — [Text](#text) |
|
||||
| `REAKTOR_SDL_GL` | `OFF` | Build SDL's OpenGL and GLES drivers on Linux and the BSDs |
|
||||
| `REAKTOR_SAMPLES`, `REAKTOR_TESTS` | `ON` at the top | Build the samples, and the tests in `tools/` |
|
||||
| `REAKTOR_INSTALL` | `ON` at the top | Install rules for libreaktor's files |
|
||||
|
||||
**CMake keeps an option**, so a build without the flag keeps the last value;
|
||||
pass `=ON` to switch one back.
|
||||
@@ -674,9 +795,10 @@ Built by default and run from `build/`:
|
||||
| `laytest` | The layout engine's placement |
|
||||
| `onlaytest` | Onlay's own suite, unmodified |
|
||||
| `a11ytest` | Node identity, the diff, the pool |
|
||||
| `animtest` | Curves, retargeting, eviction |
|
||||
| `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 |
|
||||
| `texttest` | Line breaks, direction, measuring and glyph order, against `assets/fonts`; with the Text module |
|
||||
| `launchtest` | Opt-in (`./build.ps1 launchtest`): `launchApp`'s hooks by mode (`start-fail`, `quit`, `veto`, `title`, `confirm`, `confirm-cancel`), what a floater, toast or popup holds and where keys go (the `hold-` modes), and a window beside the main one (`window-text` and the `win-` modes: keys, drops, animation, title, theme, wakes, a drag, one change a frame, the picker, memory) |
|
||||
|
||||
@@ -791,9 +913,12 @@ how its language writes numbers the way it says "Save" — Polish puts
|
||||
no-break spaces between digit groups and before its symbol — and a symbol of
|
||||
letters is always kept a space off the amount: `PLN 12.00`.
|
||||
|
||||
**The language** is `--lang` when a catalog has it, else the first of the
|
||||
system's preferred languages that one has, else English, else the first
|
||||
catalog. `reaktor_locale_set` switches at any time.
|
||||
**The language** is `--lang` when a catalog has it, else the system's: the
|
||||
first of its preferred languages that a catalog has, else English, else the
|
||||
first catalog, and it changes when the system's does.
|
||||
`reaktor_locale_set(code)` switches at any time and stops following the
|
||||
system; `reaktor_locale_set(NULL)` follows it again, and
|
||||
`reaktor_locale_system()` says whether it does.
|
||||
|
||||
**Leave `.name` to the translated text**, so a screen reader reads what is
|
||||
drawn; the cost is that a switch makes each translated widget new, placed a
|
||||
|
||||
+8
-5
@@ -9,6 +9,7 @@ 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, font baking, the SDL3 backend, and the stb_truetype the Text module rasterizes with | 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 |
|
||||
| [tiny.css](https://github.com/ihsan6133/tiny.css) | The stylesheet the look comes from, compiled in | MIT |
|
||||
@@ -24,7 +25,9 @@ static, without audio, joystick, haptic, HID, sensor, camera, power, GPU,
|
||||
offscreen or the render backends Reaktor never selects. 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. kb_text_shape is one header, compiled in
|
||||
and character-name tables. NukAnim is one header, compiled in
|
||||
`core/anim/anim.c`; its own Nuklear submodule, which only its tests use, comes
|
||||
with a recursive checkout and is not built. kb_text_shape is one header, compiled in
|
||||
`core/text/kb.c`; it shapes, and the Text module rasterizes with Nuklear's
|
||||
stb_truetype.
|
||||
|
||||
@@ -120,10 +123,10 @@ 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 and plutovg statically, plus
|
||||
mojibake and kb_text_shape with the Text module, and compiles in Nuklear and
|
||||
Onlay, so it carries the zlib and MIT terms above. Each license is copied
|
||||
unchanged into `licenses/` beside the programs: ship that folder, and this
|
||||
file, with a binary.
|
||||
mojibake and kb_text_shape with the Text module, and compiles in Nuklear,
|
||||
NukAnim and Onlay, so it carries the zlib and MIT terms above. Each license
|
||||
is copied unchanged into `licenses/` beside the programs: ship that folder,
|
||||
and this file, with a binary.
|
||||
|
||||
The binary also carries the default assets in `REAKTOR_BUILTINS`, byte for
|
||||
byte: tiny.css's `core.css`, `variables-light.css` and `variables-dark.css`
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(consumer C)
|
||||
|
||||
find_package(reaktor 0.4 REQUIRED)
|
||||
|
||||
add_executable(simple WIN32 ../../samples/simple/simple.c)
|
||||
target_link_libraries(simple PRIVATE reaktor::reaktor)
|
||||
if(EMSCRIPTEN)
|
||||
set_target_properties(simple PROPERTIES SUFFIX ".html")
|
||||
endif()
|
||||
@@ -0,0 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(embedded C)
|
||||
|
||||
add_subdirectory(../.. reaktor)
|
||||
|
||||
reaktor_add_app(simple SOURCES ../../samples/simple/simple.c)
|
||||
+1
Submodule external/nukanim added at 9e4eaf6a12
@@ -0,0 +1,39 @@
|
||||
#ifndef REAKTOR_A11Y_PUBLIC_H
|
||||
#define REAKTOR_A11Y_PUBLIC_H
|
||||
|
||||
enum {
|
||||
REAKTOR_A11Y_NONE = 0,
|
||||
REAKTOR_A11Y_WINDOW,
|
||||
REAKTOR_A11Y_GROUP,
|
||||
REAKTOR_A11Y_TABLIST,
|
||||
REAKTOR_A11Y_TAB,
|
||||
REAKTOR_A11Y_BUTTON,
|
||||
REAKTOR_A11Y_LINK,
|
||||
REAKTOR_A11Y_CHECKBOX,
|
||||
REAKTOR_A11Y_RADIO,
|
||||
REAKTOR_A11Y_TEXTBOX,
|
||||
REAKTOR_A11Y_SLIDER,
|
||||
REAKTOR_A11Y_SPINBUTTON,
|
||||
REAKTOR_A11Y_PROGRESS,
|
||||
REAKTOR_A11Y_COMBOBOX,
|
||||
REAKTOR_A11Y_LISTITEM,
|
||||
REAKTOR_A11Y_TREEITEM,
|
||||
REAKTOR_A11Y_MENUBAR,
|
||||
REAKTOR_A11Y_MENU,
|
||||
REAKTOR_A11Y_MENUITEM,
|
||||
REAKTOR_A11Y_DIALOG,
|
||||
REAKTOR_A11Y_LABEL,
|
||||
REAKTOR_A11Y_ROLE_COUNT
|
||||
};
|
||||
|
||||
enum {
|
||||
REAKTOR_A11Y_FOCUSED = 1u << 0,
|
||||
REAKTOR_A11Y_CHECKED = 1u << 1,
|
||||
REAKTOR_A11Y_EXPANDED = 1u << 2,
|
||||
REAKTOR_A11Y_SELECTED = 1u << 3,
|
||||
REAKTOR_A11Y_DISABLED = 1u << 4,
|
||||
REAKTOR_A11Y_OFFSCREEN = 1u << 6,
|
||||
REAKTOR_A11Y_VOLATILE = 1u << 7
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef REAKTOR_ANIM_PUBLIC_H
|
||||
#define REAKTOR_ANIM_PUBLIC_H
|
||||
|
||||
#include "reaktor/nuklear.h"
|
||||
#include <nukanim.h>
|
||||
|
||||
#ifndef REAKTOR_APP_FWD
|
||||
#define REAKTOR_APP_FWD
|
||||
typedef struct App App;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
REAKTOR_EASE_LINEAR = 0,
|
||||
|
||||
REAKTOR_EASE_QUAD_IN, REAKTOR_EASE_QUAD_OUT, REAKTOR_EASE_QUAD_IN_OUT,
|
||||
REAKTOR_EASE_CUBIC_IN, REAKTOR_EASE_CUBIC_OUT, REAKTOR_EASE_CUBIC_IN_OUT,
|
||||
REAKTOR_EASE_QUART_IN, REAKTOR_EASE_QUART_OUT, REAKTOR_EASE_QUART_IN_OUT,
|
||||
REAKTOR_EASE_QUINT_IN, REAKTOR_EASE_QUINT_OUT, REAKTOR_EASE_QUINT_IN_OUT,
|
||||
|
||||
REAKTOR_EASE_SINE_IN, REAKTOR_EASE_SINE_OUT, REAKTOR_EASE_SINE_IN_OUT,
|
||||
REAKTOR_EASE_EXPO_IN, REAKTOR_EASE_EXPO_OUT, REAKTOR_EASE_EXPO_IN_OUT,
|
||||
REAKTOR_EASE_CIRC_IN, REAKTOR_EASE_CIRC_OUT, REAKTOR_EASE_CIRC_IN_OUT,
|
||||
|
||||
REAKTOR_EASE_BACK_IN, REAKTOR_EASE_BACK_OUT, REAKTOR_EASE_BACK_IN_OUT,
|
||||
REAKTOR_EASE_ELASTIC_IN, REAKTOR_EASE_ELASTIC_OUT,
|
||||
REAKTOR_EASE_ELASTIC_IN_OUT,
|
||||
REAKTOR_EASE_BOUNCE_IN, REAKTOR_EASE_BOUNCE_OUT,
|
||||
REAKTOR_EASE_BOUNCE_IN_OUT,
|
||||
|
||||
REAKTOR_EASE_COUNT
|
||||
};
|
||||
|
||||
float reaktor_ease_at(unsigned char curve, float t);
|
||||
const char *reaktor_ease_name(unsigned char curve);
|
||||
|
||||
float reaktor_animate(unsigned id, unsigned channel, float to,
|
||||
float ms, unsigned char curve);
|
||||
|
||||
float reaktor_anim_progress(unsigned id, unsigned channel);
|
||||
|
||||
/* The window's NukAnim context, for all of nukanim.h; its time moves every frame. */
|
||||
struct nka_context *reaktor_anim(App *app);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef REAKTOR_KEYS_H
|
||||
#define REAKTOR_KEYS_H
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
enum {
|
||||
REAKTOR_MOD_SHIFT = 1u << 0,
|
||||
REAKTOR_MOD_CTRL = 1u << 1,
|
||||
REAKTOR_MOD_ALT = 1u << 2,
|
||||
REAKTOR_MOD_CMD = 1u << 3
|
||||
};
|
||||
|
||||
typedef struct reaktor_shortcut {
|
||||
unsigned mods;
|
||||
SDL_Keycode key, key_last;
|
||||
int action;
|
||||
const char *name;
|
||||
} reaktor_shortcut;
|
||||
|
||||
int reaktor_chord(const SDL_Event *e, unsigned mods, SDL_Keycode key);
|
||||
|
||||
int reaktor_shortcut_match(const reaktor_shortcut *table, int count,
|
||||
const SDL_Event *e, int *index);
|
||||
|
||||
int reaktor_chord_text(unsigned mods, SDL_Keycode key, char *out, int cap);
|
||||
|
||||
int reaktor_shortcut_text(const reaktor_shortcut *table, int count,
|
||||
int action, int index, char *out, int cap);
|
||||
|
||||
#endif
|
||||
@@ -121,6 +121,19 @@ void reaktor_set_title(App *app, const char *title);
|
||||
void reaktor_set_confirm_close(App *app, const char *question);
|
||||
void *reaktor_user(App *app);
|
||||
|
||||
SDL_Window *reaktor_sdl_window(App *app);
|
||||
SDL_Renderer *reaktor_sdl_renderer(App *app);
|
||||
/* An SVG asset at px, for a tray or window icon of one's own; the caller
|
||||
* destroys it. NULL when the asset cannot be read. */
|
||||
SDL_Surface *reaktor_icon_surface(const char *name, int px);
|
||||
int reaktor_dark(App *app);
|
||||
reaktor_theme reaktor_get_theme(App *app);
|
||||
/* --lang's value, or NULL; the language in use is reaktor_locale_current(). */
|
||||
const char *reaktor_lang_pref(App *app);
|
||||
/* The main window's. */
|
||||
void reaktor_set_borderless(App *app, int on);
|
||||
int reaktor_borderless(App *app);
|
||||
|
||||
/* Main thread. Answers 0 on the web. */
|
||||
int reaktor_window_open(App *app, const reaktor_window *window);
|
||||
void reaktor_window_close(App *app, int id);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef REAKTOR_LOCALE_PUBLIC_H
|
||||
#define REAKTOR_LOCALE_PUBLIC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void reaktor_locale_start(const char *lang);
|
||||
int reaktor_locale_count(void);
|
||||
const char *reaktor_locale_code(int index);
|
||||
const char *reaktor_locale_name(int index);
|
||||
/* NULL follows the system's language, and keeps following it. */
|
||||
int reaktor_locale_set(const char *code);
|
||||
int reaktor_locale_system(void);
|
||||
const char *reaktor_locale_current(void);
|
||||
|
||||
const char *reaktor_tr(const char *key);
|
||||
const char *reaktor_trn(const char *key, unsigned long n, char *buf, size_t cap);
|
||||
|
||||
const char *reaktor_format_number(char *buf, size_t cap, double value,
|
||||
int decimals);
|
||||
const char *reaktor_format_money(char *buf, size_t cap, double amount,
|
||||
const char *currency);
|
||||
|
||||
enum {
|
||||
REAKTOR_DATE_SHORT,
|
||||
REAKTOR_DATE_LONG,
|
||||
REAKTOR_DATE_FULL,
|
||||
REAKTOR_TIME_SHORT
|
||||
};
|
||||
|
||||
struct tm;
|
||||
const char *reaktor_format_date(char *buf, size_t cap, const struct tm *t,
|
||||
int style);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef REAKTOR_NUKLEAR_H
|
||||
#define REAKTOR_NUKLEAR_H
|
||||
|
||||
#define NK_INCLUDE_FIXED_TYPES
|
||||
#define NK_INCLUDE_STANDARD_IO
|
||||
#define NK_INCLUDE_STANDARD_VARARGS
|
||||
#define NK_INCLUDE_DEFAULT_ALLOCATOR
|
||||
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
|
||||
#define NK_INCLUDE_COMMAND_USERDATA
|
||||
#define NK_INCLUDE_FONT_BAKING
|
||||
#define NK_INCLUDE_DEFAULT_FONT
|
||||
|
||||
/* A browser delivers press and release in one task. */
|
||||
#define NK_BUTTON_TRIGGER_ON_RELEASE
|
||||
|
||||
#include <stddef.h>
|
||||
#include <nuklear.h>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef REAKTOR_REAKTOR_H
|
||||
#define REAKTOR_REAKTOR_H
|
||||
|
||||
#include "reaktor/nuklear.h"
|
||||
#include "reaktor/launch.h"
|
||||
#include "reaktor/widgets.h"
|
||||
#include "reaktor/keys.h"
|
||||
#include "reaktor/a11y.h"
|
||||
#include "reaktor/ui.h"
|
||||
#include "reaktor/anim.h"
|
||||
#include "reaktor/locale.h"
|
||||
#include "reaktor/style.h"
|
||||
#include "reaktor/text.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef REAKTOR_STYLE_PUBLIC_H
|
||||
#define REAKTOR_STYLE_PUBLIC_H
|
||||
|
||||
enum { REAKTOR_SIDE_TOP = 0, REAKTOR_SIDE_RIGHT, REAKTOR_SIDE_BOTTOM, REAKTOR_SIDE_LEFT };
|
||||
enum { REAKTOR_CORNER_TL = 0, REAKTOR_CORNER_TR, REAKTOR_CORNER_BR, REAKTOR_CORNER_BL };
|
||||
|
||||
typedef struct reaktor_style {
|
||||
unsigned char bg[4];
|
||||
unsigned char fg[4];
|
||||
unsigned char border_col[4];
|
||||
|
||||
float border;
|
||||
float rounding;
|
||||
float pad_x, pad_y;
|
||||
|
||||
float pad[4];
|
||||
float border_w[4];
|
||||
float radius[4];
|
||||
float margin[4];
|
||||
|
||||
float width, height;
|
||||
float min_width, min_height;
|
||||
float max_width, max_height;
|
||||
float line_height;
|
||||
float opacity;
|
||||
|
||||
int font_px;
|
||||
int bold;
|
||||
int matched;
|
||||
} reaktor_style;
|
||||
|
||||
void reaktor_style_get(const char *selector, reaktor_style *out);
|
||||
|
||||
void reaktor_style_darken(unsigned char rgba[4], float amount);
|
||||
|
||||
int reaktor_style_token(const char *name, unsigned char rgba[4]);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef REAKTOR_TEXT_PUBLIC_H
|
||||
#define REAKTOR_TEXT_PUBLIC_H
|
||||
|
||||
/* Where the next line starts, at or before limit; 0 if nowhere. */
|
||||
int reaktor_text_break(const char *s, int len, int limit);
|
||||
int reaktor_text_rtl(const char *s, int len);
|
||||
void reaktor_text_describe(char *buf, int cap);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,152 @@
|
||||
#ifndef REAKTOR_UI_PUBLIC_H
|
||||
#define REAKTOR_UI_PUBLIC_H
|
||||
|
||||
#include "reaktor/nuklear.h"
|
||||
#include "reaktor/a11y.h"
|
||||
|
||||
#ifndef REAKTOR_APP_FWD
|
||||
#define REAKTOR_APP_FWD
|
||||
typedef struct App App;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
REAKTOR_RSS_ENTRY,
|
||||
REAKTOR_RSS_SDL,
|
||||
REAKTOR_RSS_WINDOW,
|
||||
REAKTOR_RSS_ICON,
|
||||
REAKTOR_RSS_NUKLEAR,
|
||||
REAKTOR_RSS_FONT,
|
||||
REAKTOR_RSS_STYLE,
|
||||
REAKTOR_RSS_STEPS
|
||||
};
|
||||
|
||||
struct nk_color reaktor_col(const unsigned char rgba[4]);
|
||||
struct nk_color reaktor_token(const char *name,
|
||||
struct nk_color def);
|
||||
struct nk_color reaktor_visible(struct nk_color want,
|
||||
struct nk_color behind,
|
||||
struct nk_color fallback);
|
||||
/* The body rule's background, or --background-body when no sheet sets one. */
|
||||
struct nk_color reaktor_page_color(App *app);
|
||||
/* The link rule's color, or --links when no sheet sets one. */
|
||||
struct nk_color reaktor_accent_color(App *app);
|
||||
const struct nk_user_font *reaktor_font(App *app, int px, int bold);
|
||||
|
||||
struct nk_image reaktor_ionicon(App *app, const char *name, int px);
|
||||
/* In stroke's color; sw is the stroke width, 0 for the default at px. */
|
||||
struct nk_image reaktor_ionicon_exact(App *app, const char *name, int px,
|
||||
struct nk_color stroke, float sw);
|
||||
/* That Ionicon drawn centered in slot on the current window's canvas. */
|
||||
void reaktor_glyph_at(App *app, struct nk_context *ctx, struct nk_rect slot,
|
||||
const char *name, struct nk_color col, int px, float sw);
|
||||
|
||||
#define REAKTOR_MARK "assets/icons/reaktor-icon.svg"
|
||||
/* An SVG by asset name; ?stroke=#rrggbb, &fill=, &sw= recolor it. */
|
||||
struct nk_image reaktor_svg(App *app, const char *src, int px);
|
||||
|
||||
void reaktor_fill_round(App *app, struct nk_command_buffer *cv,
|
||||
struct nk_rect b, float rounding, struct nk_color col);
|
||||
void reaktor_edge_round(App *app, struct nk_command_buffer *cv,
|
||||
struct nk_rect b, float rounding, float width,
|
||||
struct nk_color col);
|
||||
struct nk_color reaktor_on(struct nk_color bg);
|
||||
|
||||
void reaktor_hot(App *app, struct nk_rect r, int cursor, int repaint);
|
||||
void reaktor_hot_top(App *app, struct nk_rect r, int cursor, int repaint);
|
||||
void reaktor_hot_follow(App *app, struct nk_rect r, int cursor);
|
||||
|
||||
int reaktor_button_label(App *app, struct nk_context *ctx, const char *label);
|
||||
int reaktor_button_icon(App *app, struct nk_context *ctx,
|
||||
const char *ionicon, const char *label);
|
||||
/* A styled single-line field over buf, which holds *len bytes of cap; hint
|
||||
* shows while it is empty, and pad_x, pad_y above 0 replace the padding. */
|
||||
nk_flags reaktor_field_text(App *app, struct nk_context *ctx, nk_flags flags,
|
||||
char *buf, int *len, int cap, const char *hint,
|
||||
nk_plugin_filter filter, float pad_x, float pad_y);
|
||||
void reaktor_slider_bar(App *app, struct nk_context *ctx, unsigned id,
|
||||
float *val, float lo, float hi, float step);
|
||||
|
||||
void reaktor_progress_bar(App *app, struct nk_context *ctx, nk_size *cur,
|
||||
nk_size max, int modifiable);
|
||||
|
||||
void reaktor_chevron_at(App *app, struct nk_context *ctx, struct nk_rect slot,
|
||||
const char *name, struct nk_color col);
|
||||
|
||||
int reaktor_button_accent(App *app, struct nk_context *ctx, const char *label);
|
||||
const struct nk_user_font *reaktor_style_font(App *app,
|
||||
const char *selector,
|
||||
int px, int bold);
|
||||
float reaktor_popup_rounding(void);
|
||||
|
||||
#define REAKTOR_MENU_ROW 22.0f
|
||||
#define REAKTOR_MENU_GAP 2.0f
|
||||
void reaktor_menu_style_push(struct nk_context *ctx);
|
||||
void reaktor_menu_style_pop(struct nk_context *ctx);
|
||||
float reaktor_menu_height(int rows);
|
||||
void reaktor_menu_edge(App *app, struct nk_context *ctx);
|
||||
typedef struct reaktor_toast_spec {
|
||||
const char *text;
|
||||
const char *icon;
|
||||
const char *action;
|
||||
void (*on_action)(App *app, void *user);
|
||||
void (*content)(App *app, struct nk_context *ctx, void *user);
|
||||
float content_w;
|
||||
void *user;
|
||||
int timeout_ms;
|
||||
int no_close;
|
||||
} reaktor_toast_spec;
|
||||
|
||||
/* Main thread; hooks get the main window's App. */
|
||||
void reaktor_toast(App *app, const reaktor_toast_spec *spec);
|
||||
|
||||
int reaktor_menu_item(App *app, struct nk_context *ctx, const char *label,
|
||||
const char *accel, int contextual);
|
||||
|
||||
unsigned reaktor_note(App *app, unsigned char role, const char *name,
|
||||
const char *value, unsigned state,
|
||||
struct nk_rect bounds);
|
||||
unsigned reaktor_note_push(App *app, unsigned char role, const char *name,
|
||||
const char *value, unsigned state,
|
||||
struct nk_rect bounds);
|
||||
void reaktor_note_pop(App *app);
|
||||
|
||||
int reaktor_focus_activated(App *app, unsigned id);
|
||||
void reaktor_focus_area(App *app, struct nk_rect area, unsigned node);
|
||||
int reaktor_focus_scroll(App *app, struct nk_rect *reveal);
|
||||
|
||||
void reaktor_note_keys(App *app, unsigned id, const char *keys);
|
||||
void reaktor_note_value(App *app, unsigned id, const char *value);
|
||||
void reaktor_note_bounds(App *app, unsigned id, struct nk_rect r);
|
||||
unsigned reaktor_note_here(App *app, struct nk_context *ctx,
|
||||
unsigned char role, const char *name,
|
||||
unsigned state);
|
||||
|
||||
int reaktor_file_open(App *app);
|
||||
|
||||
typedef struct reaktor_diag {
|
||||
const char *renderer;
|
||||
const char *mode;
|
||||
const char *frame_rate;
|
||||
const char *drag_rate;
|
||||
const char *font;
|
||||
int vsync, dark, sheets;
|
||||
const char *aa;
|
||||
float scale, style_ms, build_ms, render_ms, present_ms;
|
||||
float frame_gap_ms;
|
||||
float cpu_ms_per_frame;
|
||||
int hover_gap_ms;
|
||||
unsigned long nk_bytes, nk_used, icon_bytes;
|
||||
unsigned long rss_bytes, private_bytes;
|
||||
int icons;
|
||||
int atlas_w, atlas_h, atlas_bpp;
|
||||
unsigned long rss_at[REAKTOR_RSS_STEPS];
|
||||
unsigned long priv_at[REAKTOR_RSS_STEPS];
|
||||
} reaktor_diag;
|
||||
|
||||
void reaktor_diagnostics(App *app, reaktor_diag *out);
|
||||
void reaktor_frame_ms(App *app, double *build, double *render, double *present);
|
||||
|
||||
void reaktor_process_memory(size_t *rss, size_t *priv);
|
||||
double reaktor_process_cpu_ms(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,275 @@
|
||||
#ifndef REAKTOR_WIDGETS_H
|
||||
#define REAKTOR_WIDGETS_H
|
||||
|
||||
#include "reaktor/nuklear.h"
|
||||
|
||||
enum {
|
||||
REAKTOR_LAY_ROW = 0,
|
||||
REAKTOR_LAY_COLUMN,
|
||||
REAKTOR_LAY_FREE
|
||||
};
|
||||
|
||||
enum {
|
||||
REAKTOR_LAY_FILL_X = 1u << 0,
|
||||
REAKTOR_LAY_FILL_Y = 1u << 1,
|
||||
REAKTOR_LAY_WRAP = 1u << 2,
|
||||
REAKTOR_LAY_CENTER_X = 1u << 3,
|
||||
REAKTOR_LAY_CENTER_Y = 1u << 4,
|
||||
REAKTOR_LAY_PACK_CENTER = 1u << 5,
|
||||
REAKTOR_LAY_PACK_END = 1u << 6,
|
||||
REAKTOR_LAY_PACK_SPREAD = 1u << 7
|
||||
};
|
||||
|
||||
typedef struct reaktor_box {
|
||||
unsigned char dir;
|
||||
const char *name;
|
||||
float w, h;
|
||||
float weight;
|
||||
float gap;
|
||||
float ml, mt, mr, mb;
|
||||
unsigned flags;
|
||||
} reaktor_box;
|
||||
|
||||
void reaktor_box_open(unsigned char dir, const reaktor_box *b);
|
||||
void reaktor_box_close(void);
|
||||
|
||||
#define REAKTOR_BOX_SCOPE_(axis, ...) \
|
||||
for (int reaktor_box_scope_ = \
|
||||
(reaktor_box_open((unsigned char)(axis), \
|
||||
&(reaktor_box){ 0, __VA_ARGS__ }), 1); \
|
||||
reaktor_box_scope_; \
|
||||
reaktor_box_scope_ = (reaktor_box_close(), 0))
|
||||
|
||||
int reaktor_box_rect(struct nk_rect *out);
|
||||
|
||||
unsigned reaktor_box_id(void);
|
||||
|
||||
#define REAKTOR_ROW(...) REAKTOR_BOX_SCOPE_(REAKTOR_LAY_ROW, __VA_ARGS__)
|
||||
#define REAKTOR_COLUMN(...) REAKTOR_BOX_SCOPE_(REAKTOR_LAY_COLUMN, __VA_ARGS__)
|
||||
#define REAKTOR_FREE(...) REAKTOR_BOX_SCOPE_(REAKTOR_LAY_FREE, __VA_ARGS__)
|
||||
|
||||
void reaktor_gap(float w, float h);
|
||||
|
||||
void reaktor_soak(void);
|
||||
|
||||
typedef void (*reaktor_action)(void *user);
|
||||
|
||||
typedef struct reaktor_handler {
|
||||
reaktor_action fn;
|
||||
void *user;
|
||||
} reaktor_handler;
|
||||
|
||||
enum { REAKTOR_LEFT = 0, REAKTOR_CENTRE, REAKTOR_RIGHT };
|
||||
|
||||
typedef struct reaktor_button_spec {
|
||||
const char *label;
|
||||
const char *icon;
|
||||
const char *name;
|
||||
const char *style;
|
||||
const char *keys;
|
||||
reaktor_box box;
|
||||
reaktor_handler on_press;
|
||||
unsigned char accent;
|
||||
unsigned char disabled;
|
||||
unsigned char repeat;
|
||||
unsigned char fit_content;
|
||||
} reaktor_button_spec;
|
||||
|
||||
int reaktor_button(const reaktor_button_spec *s);
|
||||
|
||||
typedef struct reaktor_label_spec {
|
||||
const char *text;
|
||||
const char *name;
|
||||
const char *value;
|
||||
const char *style;
|
||||
const char *color;
|
||||
reaktor_box box;
|
||||
unsigned char align;
|
||||
unsigned char wrap;
|
||||
unsigned char silent;
|
||||
} reaktor_label_spec;
|
||||
|
||||
void reaktor_label(const reaktor_label_spec *s);
|
||||
|
||||
typedef struct reaktor_swatch_spec {
|
||||
const char *name;
|
||||
struct nk_color fill;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
reaktor_handler on_press;
|
||||
} reaktor_swatch_spec;
|
||||
|
||||
int reaktor_swatch(const reaktor_swatch_spec *s);
|
||||
|
||||
typedef struct reaktor_icon_spec {
|
||||
const char *name;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char accent;
|
||||
} reaktor_icon_spec;
|
||||
|
||||
void reaktor_icon(const reaktor_icon_spec *s);
|
||||
|
||||
typedef struct reaktor_field_spec {
|
||||
char *buf;
|
||||
int *len;
|
||||
int cap;
|
||||
const char *hint;
|
||||
const char *name;
|
||||
const char *style;
|
||||
float pad_x, pad_y;
|
||||
nk_plugin_filter filter;
|
||||
reaktor_box box;
|
||||
unsigned char multiline;
|
||||
} reaktor_field_spec;
|
||||
|
||||
void reaktor_field(const reaktor_field_spec *s);
|
||||
|
||||
typedef struct reaktor_check_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
nk_bool *on;
|
||||
unsigned *flags;
|
||||
unsigned bit;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char box_right;
|
||||
} reaktor_check_spec;
|
||||
|
||||
int reaktor_check(const reaktor_check_spec *s);
|
||||
|
||||
typedef struct reaktor_radio_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
int *choice;
|
||||
int value;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_radio_spec;
|
||||
|
||||
int reaktor_radio(const reaktor_radio_spec *s);
|
||||
|
||||
typedef struct reaktor_select_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
nk_bool *on;
|
||||
const char *icon;
|
||||
unsigned char disc;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char centered;
|
||||
} reaktor_select_spec;
|
||||
|
||||
int reaktor_select(const reaktor_select_spec *s);
|
||||
|
||||
typedef struct reaktor_slider_spec {
|
||||
const char *name;
|
||||
const char *text;
|
||||
float *value;
|
||||
int *ivalue;
|
||||
float lo, hi, step;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_slider_spec;
|
||||
|
||||
void reaktor_slider(const reaktor_slider_spec *s);
|
||||
|
||||
typedef struct reaktor_progress_spec {
|
||||
const char *name;
|
||||
nk_size *value;
|
||||
nk_size max;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char modifiable;
|
||||
} reaktor_progress_spec;
|
||||
|
||||
void reaktor_progress(const reaktor_progress_spec *s);
|
||||
|
||||
typedef struct reaktor_knob_spec {
|
||||
const char *name;
|
||||
float *value;
|
||||
float lo, hi;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_knob_spec;
|
||||
|
||||
void reaktor_knob(const reaktor_knob_spec *s);
|
||||
|
||||
typedef struct reaktor_property_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
int *ivalue;
|
||||
float *fvalue;
|
||||
double *dvalue;
|
||||
double lo, hi, step;
|
||||
float grain;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_property_spec;
|
||||
|
||||
void reaktor_property(const reaktor_property_spec *s);
|
||||
|
||||
typedef struct reaktor_combo_spec {
|
||||
const char *label;
|
||||
const char *name;
|
||||
float body_h;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char disc;
|
||||
const struct nk_color *swatch;
|
||||
} reaktor_combo_spec;
|
||||
|
||||
int reaktor_combo_open(const reaktor_combo_spec *s);
|
||||
void reaktor_combo_close(void);
|
||||
|
||||
#define REAKTOR_COMBO(...) \
|
||||
for (int reaktor_combo_scope_ = \
|
||||
reaktor_combo_open(&(reaktor_combo_spec){ __VA_ARGS__ }); \
|
||||
reaktor_combo_scope_; \
|
||||
reaktor_combo_scope_ = (reaktor_combo_close(), 0))
|
||||
|
||||
int reaktor_combo_item(const char *label, int chosen);
|
||||
|
||||
typedef struct reaktor_colour_spec {
|
||||
const char *name;
|
||||
struct nk_colorf *value;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
} reaktor_colour_spec;
|
||||
|
||||
void reaktor_colour_pick(const reaktor_colour_spec *s);
|
||||
|
||||
typedef struct reaktor_link_spec {
|
||||
const char *text;
|
||||
const char *name;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
reaktor_handler on_press;
|
||||
unsigned char active;
|
||||
} reaktor_link_spec;
|
||||
|
||||
int reaktor_link(const reaktor_link_spec *s);
|
||||
|
||||
enum { REAKTOR_NAV_PAGES, REAKTOR_NAV_CHOICE, REAKTOR_NAV_ACTIONS };
|
||||
|
||||
typedef struct reaktor_nav_spec {
|
||||
const char *const *items;
|
||||
const char *const *icons;
|
||||
const char *const *keys;
|
||||
int count;
|
||||
int *chosen;
|
||||
const char *name;
|
||||
const char *list_keys;
|
||||
const char *style;
|
||||
reaktor_box box;
|
||||
unsigned char kind;
|
||||
unsigned char narrow;
|
||||
} reaktor_nav_spec;
|
||||
|
||||
typedef reaktor_nav_spec reaktor_sidebar_spec;
|
||||
typedef reaktor_nav_spec reaktor_tabs_spec;
|
||||
|
||||
int reaktor_sidebar(const reaktor_sidebar_spec *s);
|
||||
int reaktor_tabs(const reaktor_tabs_spec *s);
|
||||
|
||||
#endif
|
||||
+315
-29
@@ -18,8 +18,8 @@ effective_dark(const App *app)
|
||||
return reaktor_prefers_dark() > 0;
|
||||
}
|
||||
|
||||
size_t reaktor_rss[RSS_STEPS];
|
||||
size_t reaktor_priv[RSS_STEPS];
|
||||
size_t reaktor_rss[REAKTOR_RSS_STEPS];
|
||||
size_t reaktor_priv[REAKTOR_RSS_STEPS];
|
||||
|
||||
static reaktor_launch g_launch;
|
||||
static App *g_app;
|
||||
@@ -215,23 +215,38 @@ load_theme(App *app)
|
||||
app->style_ms_x100 = (int)(100000.0 * (double)(t1 - t0) /
|
||||
(double)SDL_GetPerformanceFrequency());
|
||||
|
||||
app->page = reaktor_style_token("--background-body", c)
|
||||
? nk_rgba(c[0], c[1], c[2], c[3]) : nk_rgb(247, 247, 247);
|
||||
{
|
||||
reaktor_style body;
|
||||
|
||||
reaktor_style_get("body", &body);
|
||||
app->page = body.matched && body.bg[3]
|
||||
? nk_rgba(body.bg[0], body.bg[1], body.bg[2], body.bg[3])
|
||||
: reaktor_style_token("--background-body", c)
|
||||
? nk_rgba(c[0], c[1], c[2], c[3]) : nk_rgb(247, 247, 247);
|
||||
app->text = body.matched && body.fg[3]
|
||||
? nk_rgba(body.fg[0], body.fg[1], body.fg[2], body.fg[3])
|
||||
: reaktor_style_token("--text-main", c)
|
||||
? nk_rgba(c[0], c[1], c[2], c[3]) : nk_rgb(51, 51, 51);
|
||||
}
|
||||
{
|
||||
reaktor_style link;
|
||||
|
||||
reaktor_style_get("a:link", &link);
|
||||
app->accent = link.matched && link.fg[3]
|
||||
? nk_rgba(link.fg[0], link.fg[1], link.fg[2], link.fg[3])
|
||||
: reaktor_style_token("--links", c)
|
||||
? nk_rgba(c[0], c[1], c[2], c[3]) : app->text;
|
||||
}
|
||||
app->card_bg = reaktor_style_token("--background", c)
|
||||
? nk_rgba(c[0], c[1], c[2], c[3]) : nk_rgb(226, 226, 226);
|
||||
app->text = reaktor_style_token("--text-main", c)
|
||||
? nk_rgba(c[0], c[1], c[2], c[3]) : nk_rgb(51, 51, 51);
|
||||
if (reaktor_style_token("--text-muted", c))
|
||||
SDL_snprintf(app->icon_hex, sizeof(app->icon_hex),
|
||||
"#%02x%02x%02x", c[0], c[1], c[2]);
|
||||
else
|
||||
SDL_strlcpy(app->icon_hex, "#6a6a6a", sizeof(app->icon_hex));
|
||||
|
||||
if (reaktor_style_token("--links", c))
|
||||
SDL_snprintf(app->accent_hex, sizeof(app->accent_hex),
|
||||
"#%02x%02x%02x", c[0], c[1], c[2]);
|
||||
else
|
||||
SDL_strlcpy(app->accent_hex, REAKTOR_BRAND, sizeof(app->accent_hex));
|
||||
SDL_snprintf(app->accent_hex, sizeof(app->accent_hex), "#%02x%02x%02x",
|
||||
app->accent.r, app->accent.g, app->accent.b);
|
||||
|
||||
reaktor_window_set_dark(app->win, app->dark);
|
||||
|
||||
@@ -517,7 +532,7 @@ app_init(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
App *app;
|
||||
|
||||
reaktor_rss_mark(RSS_ENTRY);
|
||||
reaktor_rss_mark(REAKTOR_RSS_ENTRY);
|
||||
app = (App *)SDL_calloc(1, sizeof(App));
|
||||
if (!app) return SDL_APP_FAILURE;
|
||||
*appstate = app;
|
||||
@@ -546,7 +561,7 @@ app_init(void **appstate, int argc, char *argv[])
|
||||
if (g_launch.console == REAKTOR_CONSOLE_DEBUG)
|
||||
SDL_SetLogPriorities(SDL_LOG_PRIORITY_DEBUG);
|
||||
|
||||
reaktor_rss_mark(RSS_SDL);
|
||||
reaktor_rss_mark(REAKTOR_RSS_SDL);
|
||||
take_assets(app);
|
||||
|
||||
if (app->renderer_pref && SDL_strcmp(app->renderer_pref, "software") != 0) {
|
||||
@@ -645,21 +660,21 @@ app_init(void **appstate, int argc, char *argv[])
|
||||
if (app->borderless && g_launch.window.hit_test)
|
||||
SDL_SetWindowHitTest(app->win, g_launch.window.hit_test, app);
|
||||
|
||||
reaktor_rss_mark(RSS_WINDOW);
|
||||
reaktor_rss_mark(REAKTOR_RSS_WINDOW);
|
||||
|
||||
reaktor_set_window_icon(app->win, reaktor_launch_icon());
|
||||
reaktor_set_scale(reaktor_dpi_query_scale(app->win));
|
||||
apply_render_scale(app);
|
||||
reaktor_rss_mark(RSS_ICON);
|
||||
reaktor_rss_mark(REAKTOR_RSS_ICON);
|
||||
|
||||
app->ctx = nk_sdl_init(app->win, app->ren, nk_sdl_allocator());
|
||||
if (!app->ctx) return fail(app, "The interface could not start");
|
||||
reaktor_rss_mark(RSS_NUKLEAR);
|
||||
reaktor_rss_mark(REAKTOR_RSS_NUKLEAR);
|
||||
|
||||
/* Before the atlas, which bakes what the catalogs need. */
|
||||
reaktor_locale_start(app->lang_pref);
|
||||
rebuild_font(app);
|
||||
reaktor_rss_mark(RSS_FONT);
|
||||
reaktor_rss_mark(REAKTOR_RSS_FONT);
|
||||
|
||||
app->cur_default = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT);
|
||||
app->cur_pointer = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_POINTER);
|
||||
@@ -678,7 +693,7 @@ app_init(void **appstate, int argc, char *argv[])
|
||||
|
||||
take_pending(app);
|
||||
load_theme(app);
|
||||
reaktor_rss_mark(RSS_STYLE);
|
||||
reaktor_rss_mark(REAKTOR_RSS_STYLE);
|
||||
|
||||
app->dirty = 1;
|
||||
|
||||
@@ -944,6 +959,7 @@ take_event(App *app, SDL_Event *event)
|
||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||
case SDL_EVENT_SYSTEM_THEME_CHANGED:
|
||||
case SDL_EVENT_LOCALE_CHANGED:
|
||||
case SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED:
|
||||
app->dirty = 1;
|
||||
break;
|
||||
@@ -1002,6 +1018,11 @@ take_event(App *app, SDL_Event *event)
|
||||
if (app->theme_mode == REAKTOR_THEME_SYSTEM) load_theme(app);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_LOCALE_CHANGED:
|
||||
if (!app->secondary && reaktor_locale_system() && reaktor_locale_set(NULL))
|
||||
reaktor_windows_dirty();
|
||||
break;
|
||||
|
||||
case SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED:
|
||||
if (app->secondary) break;
|
||||
reaktor_set_scale(reaktor_dpi_query_scale(app->win));
|
||||
@@ -1139,6 +1160,198 @@ bare_quit(App *app)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
feed(App *app, SDL_Event *event)
|
||||
{
|
||||
if (hold_for_next_frame(app, event)) app->dirty = 1;
|
||||
else take_event(app, event);
|
||||
}
|
||||
|
||||
enum { TOUCH_NONE, TOUCH_PRESSED, TOUCH_CAUGHT, TOUCH_DRAGGING, TOUCH_SCROLLING };
|
||||
|
||||
#define TOUCH_SLOP 8.0f
|
||||
#define FLING_TAU_MS 325.0f
|
||||
#define FLING_MIN 60.0f
|
||||
#define FLING_STOP 20.0f
|
||||
|
||||
static void
|
||||
touch_pointer(App *app, float x, float y, int release)
|
||||
{
|
||||
SDL_Event e;
|
||||
|
||||
SDL_zero(e);
|
||||
e.type = SDL_EVENT_MOUSE_MOTION;
|
||||
e.motion.windowID = SDL_GetWindowID(app->win);
|
||||
e.motion.which = SDL_TOUCH_MOUSEID;
|
||||
e.motion.x = x;
|
||||
e.motion.y = y;
|
||||
feed(app, &e);
|
||||
if (!release) return;
|
||||
SDL_zero(e);
|
||||
e.type = SDL_EVENT_MOUSE_BUTTON_UP;
|
||||
e.button.windowID = SDL_GetWindowID(app->win);
|
||||
e.button.which = SDL_TOUCH_MOUSEID;
|
||||
e.button.button = SDL_BUTTON_LEFT;
|
||||
e.button.clicks = 1;
|
||||
e.button.x = x;
|
||||
e.button.y = y;
|
||||
feed(app, &e);
|
||||
}
|
||||
|
||||
static void
|
||||
touch_wheel(App *app, float dy)
|
||||
{
|
||||
SDL_Event e;
|
||||
|
||||
if (dy == 0.0f || app->touch_unit <= 0.0f) return;
|
||||
SDL_zero(e);
|
||||
e.type = SDL_EVENT_MOUSE_WHEEL;
|
||||
e.wheel.windowID = SDL_GetWindowID(app->win);
|
||||
e.wheel.which = SDL_TOUCH_MOUSEID;
|
||||
e.wheel.y = dy / app->touch_unit;
|
||||
e.wheel.mouse_x = app->touch_x0;
|
||||
e.wheel.mouse_y = app->touch_y0;
|
||||
feed(app, &e);
|
||||
}
|
||||
|
||||
static void
|
||||
touch_sample(App *app, float y, Uint64 ns)
|
||||
{
|
||||
app->touch_ys[app->touch_n % 4] = y;
|
||||
app->touch_ns[app->touch_n % 4] = ns;
|
||||
app->touch_n++;
|
||||
}
|
||||
|
||||
/* Nuklear moves a panel a tenth of its height per wheel step. */
|
||||
static float
|
||||
touch_unit(const App *app)
|
||||
{
|
||||
struct nk_rect b = app->body_rect;
|
||||
float h = (float)app->laid_h;
|
||||
|
||||
if (b.h > 0.0f && app->touch_x0 >= b.x && app->touch_x0 < b.x + b.w &&
|
||||
app->touch_y0 >= b.y && app->touch_y0 < b.y + b.h)
|
||||
h = b.h;
|
||||
return 0.1f * h;
|
||||
}
|
||||
|
||||
static void
|
||||
fling_start(App *app, Uint64 now)
|
||||
{
|
||||
int last = app->touch_n - 1, first = last, i;
|
||||
Uint64 t;
|
||||
float v;
|
||||
|
||||
if (last < 1 || now - app->touch_ns[last % 4] > 100000000u) return;
|
||||
for (i = last - 1; i >= 0 && i > last - 4; i--) {
|
||||
if (app->touch_ns[last % 4] - app->touch_ns[i % 4] > 100000000u) break;
|
||||
first = i;
|
||||
}
|
||||
t = app->touch_ns[last % 4] - app->touch_ns[first % 4];
|
||||
if (first == last || !t) return;
|
||||
v = (app->touch_ys[last % 4] - app->touch_ys[first % 4]) / ((float)t / 1e9f);
|
||||
if (SDL_fabsf(v) < FLING_MIN) return;
|
||||
app->fling_v = v;
|
||||
app->fling_ns = now;
|
||||
app->restore_rate = 0;
|
||||
hint(SDL_HINT_MAIN_CALLBACK_RATE, app->drag_rate);
|
||||
app->dirty = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
fling_step(App *app)
|
||||
{
|
||||
Uint64 now = SDL_GetTicksNS();
|
||||
float dt;
|
||||
|
||||
if (app->fling_v == 0.0f) return;
|
||||
dt = (float)(now - app->fling_ns) / 1e9f;
|
||||
app->fling_ns = now;
|
||||
if (app->touch_unit > 0.0f)
|
||||
nk_input_scroll(app->ctx, nk_vec2(0.0f, app->fling_v * dt / app->touch_unit));
|
||||
app->fling_v *= SDL_expf(-dt * 1000.0f / FLING_TAU_MS);
|
||||
if (SDL_fabsf(app->fling_v) < FLING_STOP) {
|
||||
app->fling_v = 0.0f;
|
||||
app->restore_rate = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* A finger that moves mostly up or down scrolls, and presses nothing. */
|
||||
static int
|
||||
touch_takes(App *app, const SDL_Event *e)
|
||||
{
|
||||
struct nk_rect r = app->field_rect;
|
||||
float dx, dy;
|
||||
int was = app->touch;
|
||||
|
||||
switch (e->type) {
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
if (e->button.which != SDL_TOUCH_MOUSEID || e->button.button != SDL_BUTTON_LEFT)
|
||||
return 0;
|
||||
app->touch_x0 = e->button.x;
|
||||
app->touch_y0 = e->button.y;
|
||||
app->touch_n = 0;
|
||||
touch_sample(app, e->button.y, e->button.timestamp);
|
||||
app->touch_in_field = app->field_rect_valid &&
|
||||
e->button.x >= r.x && e->button.x <= r.x + r.w &&
|
||||
e->button.y >= r.y && e->button.y <= r.y + r.h;
|
||||
if (app->fling_v != 0.0f) {
|
||||
app->fling_v = 0.0f;
|
||||
app->restore_rate = 2;
|
||||
app->touch = TOUCH_CAUGHT;
|
||||
return 1;
|
||||
}
|
||||
app->touch = TOUCH_PRESSED;
|
||||
return 0;
|
||||
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
if (e->motion.which != SDL_TOUCH_MOUSEID) return 0;
|
||||
switch (app->touch) {
|
||||
case TOUCH_SCROLLING:
|
||||
touch_wheel(app, e->motion.y - app->touch_last);
|
||||
app->touch_last = e->motion.y;
|
||||
touch_sample(app, e->motion.y, e->motion.timestamp);
|
||||
return 1;
|
||||
case TOUCH_PRESSED:
|
||||
case TOUCH_CAUGHT:
|
||||
dx = e->motion.x - app->touch_x0;
|
||||
dy = e->motion.y - app->touch_y0;
|
||||
if (SDL_fabsf(dx) <= TOUCH_SLOP && SDL_fabsf(dy) <= TOUCH_SLOP)
|
||||
return app->touch == TOUCH_CAUGHT;
|
||||
if (app->touch_in_field || SDL_fabsf(dy) <= SDL_fabsf(dx)) {
|
||||
if (app->touch == TOUCH_CAUGHT) return 1;
|
||||
app->touch = TOUCH_DRAGGING;
|
||||
return 0;
|
||||
}
|
||||
/* Released away from every widget, the press clicks nothing. */
|
||||
if (app->touch == TOUCH_PRESSED) touch_pointer(app, -1e4f, -1e4f, 1);
|
||||
touch_pointer(app, app->touch_x0, app->touch_y0, 0);
|
||||
app->touch = TOUCH_SCROLLING;
|
||||
app->touch_unit = touch_unit(app);
|
||||
app->touch_last = app->touch_y0 + (dy > 0.0f ? TOUCH_SLOP : -TOUCH_SLOP);
|
||||
touch_wheel(app, e->motion.y - app->touch_last);
|
||||
app->touch_last = e->motion.y;
|
||||
touch_sample(app, e->motion.y, e->motion.timestamp);
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
if (e->button.which != SDL_TOUCH_MOUSEID || e->button.button != SDL_BUTTON_LEFT)
|
||||
return 0;
|
||||
app->touch = TOUCH_NONE;
|
||||
if (was == TOUCH_SCROLLING) {
|
||||
fling_start(app, e->button.timestamp);
|
||||
return 1;
|
||||
}
|
||||
return was == TOUCH_CAUGHT;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_AppResult
|
||||
app_event(void *appstate, SDL_Event *event)
|
||||
{
|
||||
@@ -1163,8 +1376,7 @@ app_event(void *appstate, SDL_Event *event)
|
||||
}
|
||||
if (!(to = app)) return SDL_APP_CONTINUE;
|
||||
}
|
||||
if (hold_for_next_frame(to, event)) to->dirty = 1;
|
||||
else take_event(to, event);
|
||||
if (!touch_takes(to, event)) feed(to, event);
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -1214,6 +1426,7 @@ reaktor_app_due(App *app, int w, int h)
|
||||
SDL_Window *over = SDL_GetMouseFocus();
|
||||
|
||||
if (w != app->laid_w || h != app->laid_h) app->dirty = 1;
|
||||
if (app->fling_v != 0.0f) app->dirty = 1;
|
||||
|
||||
if (app->hover_pending &&
|
||||
SDL_GetTicks() - app->last_draw_ms >= g_hover_gap_ms) {
|
||||
@@ -1335,13 +1548,15 @@ reaktor_app_frame(App *app, int win_w, int win_h, const char *title,
|
||||
if (is_main) reaktor_a11y_platform_drain();
|
||||
else reaktor_a11y_platform_window_drain(app->win);
|
||||
key_click(app);
|
||||
fling_step(app);
|
||||
nk_input_end(ctx);
|
||||
ctx->style.text.color = app->text;
|
||||
file_answer(app);
|
||||
|
||||
app->focus_seen = 0;
|
||||
app->popup_lo = app->popup_hi = app->trap_lo = app->trap_hi = -1;
|
||||
reaktor_anim_scope(app);
|
||||
if (!app->anim) app->anim = reaktor_anim_create();
|
||||
if (app->anim) reaktor_anim_frame(app->anim, app->frame_gap_ms);
|
||||
reaktor_a11y_begin(&app->a11y, title, area);
|
||||
reaktor_frame_begin(app, ctx, area);
|
||||
|
||||
@@ -1400,13 +1615,7 @@ reaktor_app_frame(App *app, int win_w, int win_h, const char *title,
|
||||
reader_activate, reader_focus, app);
|
||||
}
|
||||
|
||||
{
|
||||
int n = 0;
|
||||
const reaktor_a11y_change *c = reaktor_a11y_changes(&app->a11y, &n);
|
||||
|
||||
reaktor_anim_evict(c, n);
|
||||
}
|
||||
if (reaktor_anim_tick(app->frame_gap_ms) > 0) {
|
||||
if (app->anim && reaktor_anim_settle()) {
|
||||
app->dirty = 1;
|
||||
wake_app(app);
|
||||
}
|
||||
@@ -1486,7 +1695,6 @@ app_iterate(void *appstate)
|
||||
SDL_SyncWindow(app->win);
|
||||
SDL_GetWindowSize(app->win, &w, &h);
|
||||
SDL_SetWindowSize(app->win, w, h);
|
||||
app->ctl_n = 0;
|
||||
app->dirty = 1;
|
||||
app->borderless_lock_frames = 3;
|
||||
}
|
||||
@@ -1539,6 +1747,8 @@ app_quit(void *appstate, SDL_AppResult result)
|
||||
if (app->ctx) nk_sdl_shutdown(app->ctx);
|
||||
if (app->ren) SDL_DestroyRenderer(app->ren);
|
||||
if (app->win) SDL_DestroyWindow(app->win);
|
||||
reaktor_anim_destroy(app->anim);
|
||||
app->anim = NULL;
|
||||
/* The picker's thread still writes into it. */
|
||||
if (!app->file_pending) SDL_free(app);
|
||||
g_app = NULL;
|
||||
@@ -1714,6 +1924,13 @@ reaktor_main_app(void)
|
||||
return g_app;
|
||||
}
|
||||
|
||||
struct nka_context *
|
||||
reaktor_anim(App *app)
|
||||
{
|
||||
if (app && !app->anim) app->anim = reaktor_anim_create();
|
||||
return app ? app->anim : NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
reaktor_launch_icon(void)
|
||||
{
|
||||
@@ -1726,3 +1943,72 @@ reaktor_user(App *app)
|
||||
(void)app;
|
||||
return g_launch.user;
|
||||
}
|
||||
|
||||
SDL_Window *
|
||||
reaktor_sdl_window(App *app)
|
||||
{
|
||||
return app ? app->win : NULL;
|
||||
}
|
||||
|
||||
SDL_Renderer *
|
||||
reaktor_sdl_renderer(App *app)
|
||||
{
|
||||
return app ? app->ren : NULL;
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_dark(App *app)
|
||||
{
|
||||
return app && app->dark;
|
||||
}
|
||||
|
||||
struct nk_color
|
||||
reaktor_page_color(App *app)
|
||||
{
|
||||
return app ? app->page : nk_rgb(247, 247, 247);
|
||||
}
|
||||
|
||||
struct nk_color
|
||||
reaktor_accent_color(App *app)
|
||||
{
|
||||
return app ? app->accent : nk_rgb(0, 112, 224);
|
||||
}
|
||||
|
||||
reaktor_theme
|
||||
reaktor_get_theme(App *app)
|
||||
{
|
||||
return app ? (reaktor_theme)app->theme_mode : REAKTOR_THEME_SYSTEM;
|
||||
}
|
||||
|
||||
const char *
|
||||
reaktor_lang_pref(App *app)
|
||||
{
|
||||
App *m = reaktor_main_app();
|
||||
|
||||
return app && m ? m->lang_pref : NULL;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_set_borderless(App *app, int on)
|
||||
{
|
||||
if (!app || !app->win || app->secondary || !on == !app->borderless) return;
|
||||
#ifdef __APPLE__
|
||||
if (app->borderless_lock_frames == 0) {
|
||||
app->borderless_pending = 1;
|
||||
app->dirty = 1;
|
||||
}
|
||||
#else
|
||||
app->borderless = on != 0;
|
||||
SDL_SetWindowBordered(app->win, app->borderless ? false : true);
|
||||
SDL_SetWindowHitTest(app->win,
|
||||
app->borderless ? g_launch.window.hit_test : NULL,
|
||||
app->borderless ? app : NULL);
|
||||
app->dirty = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
reaktor_borderless(App *app)
|
||||
{
|
||||
return app && app->borderless;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "internal.h"
|
||||
#include "anim.h"
|
||||
#include "declare.h"
|
||||
#include "reaktor/launch.h"
|
||||
|
||||
@@ -47,6 +48,7 @@ take_look(App *a, const App *m)
|
||||
a->page = m->page;
|
||||
a->card_bg = m->card_bg;
|
||||
a->text = m->text;
|
||||
a->accent = m->accent;
|
||||
a->clear = m->clear;
|
||||
SDL_memcpy(a->icon_hex, m->icon_hex, sizeof a->icon_hex);
|
||||
SDL_memcpy(a->accent_hex, m->accent_hex, sizeof a->accent_hex);
|
||||
@@ -77,6 +79,8 @@ teardown(App *a)
|
||||
if (a->ren) SDL_DestroyRenderer(a->ren);
|
||||
if (a->win) SDL_DestroyWindow(a->win);
|
||||
SDL_free(a->glyphs);
|
||||
reaktor_anim_destroy(a->anim);
|
||||
a->anim = NULL;
|
||||
a->win = NULL;
|
||||
a->ren = NULL;
|
||||
a->ctx = NULL;
|
||||
@@ -296,6 +300,15 @@ reaktor_windows_restyle(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_windows_dirty(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < g_win_n; i++)
|
||||
g_win[i].app->dirty = 1;
|
||||
}
|
||||
|
||||
void
|
||||
reaktor_windows_rescale(void)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#include "internal.h"
|
||||
#include "declare.h"
|
||||
#include "reaktor/launch.h"
|
||||
#include "reaktor/reaktor.h"
|
||||
#include "reaktor/main.h"
|
||||
#include "keys.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
@@ -28,19 +25,21 @@ page_shell(App *app, struct nk_context *ctx, int win_w, int win_h)
|
||||
{
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
double now_ms;
|
||||
double build, render, present;
|
||||
float t;
|
||||
int i;
|
||||
|
||||
if (!g_started) {
|
||||
g_started = 1;
|
||||
if (g_no_vsync) SDL_SetRenderVSync(app->ren, 0);
|
||||
if (g_no_vsync) SDL_SetRenderVSync(reaktor_sdl_renderer(app), 0);
|
||||
g_t0 = SDL_GetTicks();
|
||||
g_cpu0 = reaktor_process_cpu_ms();
|
||||
}
|
||||
|
||||
g_build_ms += app->build_ms_x100 / 100.0;
|
||||
g_render_ms += app->render_ms_x100 / 100.0;
|
||||
g_present_ms += app->present_ms_x100 / 100.0;
|
||||
reaktor_frame_ms(app, &build, &render, &present);
|
||||
g_build_ms += build;
|
||||
g_render_ms += render;
|
||||
g_present_ms += present;
|
||||
g_work_ms = g_build_ms + g_render_ms + g_present_ms;
|
||||
|
||||
t = (float)(SDL_GetTicks() - g_t0) / 1000.0f;
|
||||
@@ -101,7 +100,6 @@ page_shell(App *app, struct nk_context *ctx, int win_w, int win_h)
|
||||
else g_due_ns = now;
|
||||
}
|
||||
|
||||
app->dirty = 1;
|
||||
reaktor_wake(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "declare.h"
|
||||
#include "keys.h"
|
||||
#include "reaktor/launch.h"
|
||||
#include "reaktor/reaktor.h"
|
||||
#include "reaktor/main.h"
|
||||
|
||||
#define TEXT_CAP 65536
|
||||
@@ -11,7 +8,7 @@
|
||||
static struct {
|
||||
char text[TEXT_CAP];
|
||||
int len;
|
||||
char path[SC_PATH_CAP];
|
||||
char path[520];
|
||||
unsigned saved_hash;
|
||||
int saved_len;
|
||||
char status[160];
|
||||
@@ -66,7 +63,7 @@ static void
|
||||
load(const char *path)
|
||||
{
|
||||
size_t n = 0;
|
||||
char *body = reaktor_read_file(path, &n);
|
||||
char *body = (char *)SDL_LoadFile(path, &n);
|
||||
|
||||
if (!body) {
|
||||
SDL_snprintf(g.status, sizeof(g.status), "Could not read %s", path);
|
||||
@@ -76,13 +73,13 @@ load(const char *path)
|
||||
SDL_snprintf(g.status, sizeof(g.status),
|
||||
"%s is %.0f KB, and this editor holds %d KB",
|
||||
path, (double)n / 1024.0, TEXT_CAP / 1024);
|
||||
reaktor_free(body);
|
||||
SDL_free(body);
|
||||
return;
|
||||
}
|
||||
SDL_memcpy(g.text, body, n);
|
||||
g.text[n] = '\0';
|
||||
g.len = (int)n;
|
||||
reaktor_free(body);
|
||||
SDL_free(body);
|
||||
|
||||
SDL_strlcpy(g.path, path, sizeof(g.path));
|
||||
g.saved_hash = hash_of(g.text, g.len);
|
||||
|
||||
+173
-101
@@ -1,12 +1,51 @@
|
||||
#include "internal.h"
|
||||
#include "showcase.h"
|
||||
#include "declare.h"
|
||||
#include "reaktor/main.h"
|
||||
|
||||
#define TITLE_PX 16
|
||||
#define GLYPH_STROKE 2.0f
|
||||
#define BODY_PAD_X 20.0f
|
||||
|
||||
typedef struct shell_style { int items, colors, floats, vec2s, fonts; } shell_style;
|
||||
|
||||
static struct nk_rect g_ctl[3];
|
||||
static int g_ctl_n;
|
||||
static int g_show_contact;
|
||||
static float g_card_h;
|
||||
static float g_nav_room;
|
||||
static int g_nav_over;
|
||||
|
||||
static void
|
||||
pop_style(struct nk_context *ctx, shell_style f)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < f.fonts; i++) nk_style_pop_font(ctx);
|
||||
for (i = 0; i < f.vec2s; i++) nk_style_pop_vec2(ctx);
|
||||
for (i = 0; i < f.floats; i++) nk_style_pop_float(ctx);
|
||||
for (i = 0; i < f.colors; i++) nk_style_pop_color(ctx);
|
||||
for (i = 0; i < f.items; i++) nk_style_pop_style_item(ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
image_centered(struct nk_context *ctx, struct nk_image im, int px)
|
||||
{
|
||||
struct nk_rect b = nk_widget_bounds(ctx);
|
||||
float s = (float)px;
|
||||
struct nk_rect r = nk_rect(b.x + (b.w - s) * 0.5f,
|
||||
b.y + (b.h - s) * 0.5f, s, s);
|
||||
|
||||
nk_draw_image(nk_window_get_canvas(ctx), r, &im, nk_rgb(255, 255, 255));
|
||||
nk_spacing(ctx, 1);
|
||||
}
|
||||
|
||||
static struct nk_color
|
||||
text_main(void)
|
||||
{
|
||||
return reaktor_token("--text-main", nk_rgb(51, 51, 51));
|
||||
}
|
||||
|
||||
static SDL_HitTestResult SDLCALL
|
||||
window_hit_test(SDL_Window *win, const SDL_Point *pt, void *data)
|
||||
{
|
||||
App *app = (App *)data;
|
||||
int w = 0, h = 0, i;
|
||||
int left, right, top, bottom;
|
||||
|
||||
@@ -28,9 +67,10 @@ window_hit_test(SDL_Window *win, const SDL_Point *pt, void *data)
|
||||
if (right) return SDL_HITTEST_RESIZE_RIGHT;
|
||||
}
|
||||
|
||||
(void)data;
|
||||
if (pt->y < TITLEBAR_H) {
|
||||
for (i = 0; i < app->ctl_n; i++) {
|
||||
struct nk_rect r = app->ctl[i];
|
||||
for (i = 0; i < g_ctl_n; i++) {
|
||||
struct nk_rect r = g_ctl[i];
|
||||
const int m = 4;
|
||||
if (pt->x >= r.x - m && pt->x <= r.x + r.w + m &&
|
||||
pt->y >= r.y - m && pt->y <= r.y + r.h + m)
|
||||
@@ -83,7 +123,7 @@ set_tab(App *app, int tab)
|
||||
{
|
||||
if (tab == sample_tab()) return;
|
||||
g_tab = tab;
|
||||
app->dirty = 1;
|
||||
reaktor_wake(app);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -91,19 +131,19 @@ titlebar_button(App *app, struct nk_context *ctx, const char *glyph,
|
||||
const char *name, int px)
|
||||
{
|
||||
struct nk_rect b = nk_widget_bounds(ctx);
|
||||
style_frame f = { 0, 0, 0, 0, 0 };
|
||||
shell_style f = { 0, 0, 0, 0, 0 };
|
||||
unsigned char c[4];
|
||||
struct nk_color clear = nk_rgba(0, 0, 0, 0);
|
||||
struct nk_color wash = reaktor_style_token("--background-hover", c)
|
||||
? col_of(c) : nk_rgba(255, 255, 255, 26);
|
||||
? reaktor_col(c) : nk_rgba(255, 255, 255, 26);
|
||||
char src[176];
|
||||
float pad_x, pad_y;
|
||||
int clicked;
|
||||
|
||||
hot_push(app, b, 1, 1);
|
||||
reaktor_hot(app, b, 1, 1);
|
||||
reaktor_note(app, REAKTOR_A11Y_BUTTON, name, NULL, 0, b);
|
||||
if (app->ctl_n < (int)(sizeof(app->ctl) / sizeof(app->ctl[0])))
|
||||
app->ctl[app->ctl_n++] = b;
|
||||
if (g_ctl_n < (int)(sizeof(g_ctl) / sizeof(g_ctl[0])))
|
||||
g_ctl[g_ctl_n++] = b;
|
||||
|
||||
nk_style_push_style_item(ctx, &ctx->style.button.normal,
|
||||
nk_style_item_color(clear));
|
||||
@@ -127,19 +167,21 @@ titlebar_button(App *app, struct nk_context *ctx, const char *glyph,
|
||||
nk_vec2(pad_x, pad_y));
|
||||
f.vec2s = 2;
|
||||
|
||||
if (app->dark) {
|
||||
SDL_snprintf(src, sizeof(src),
|
||||
"external/ionicons/src/svg/%s.svg?stroke=%s&sw=%.2f",
|
||||
glyph, app->icon_hex, (double)GLYPH_STROKE);
|
||||
if (reaktor_dark(app)) {
|
||||
if (!reaktor_style_token("--text-muted", c)) {
|
||||
c[0] = 0x6a; c[1] = 0x6a; c[2] = 0x6a;
|
||||
}
|
||||
} else {
|
||||
SDL_snprintf(src, sizeof(src),
|
||||
"external/ionicons/src/svg/%s.svg"
|
||||
"?stroke=#%02x%02x%02x&sw=%.2f",
|
||||
glyph, app->text.r, app->text.g, app->text.b,
|
||||
(double)GLYPH_STROKE);
|
||||
}
|
||||
struct nk_color t = text_main();
|
||||
|
||||
clicked = nk_button_image_label(ctx, icon(app, src, px), "",
|
||||
c[0] = t.r; c[1] = t.g; c[2] = t.b;
|
||||
}
|
||||
SDL_snprintf(src, sizeof(src),
|
||||
"external/ionicons/src/svg/%s.svg"
|
||||
"?stroke=#%02x%02x%02x&sw=%.2f",
|
||||
glyph, c[0], c[1], c[2], (double)GLYPH_STROKE);
|
||||
|
||||
clicked = nk_button_image_label(ctx, reaktor_svg(app, src, px), "",
|
||||
NK_TEXT_CENTERED);
|
||||
pop_style(ctx, f);
|
||||
return clicked;
|
||||
@@ -149,10 +191,11 @@ static void
|
||||
titlebar(App *app, struct nk_context *ctx, int win_w)
|
||||
{
|
||||
unsigned char c[4];
|
||||
int maximised = (SDL_GetWindowFlags(app->win) & SDL_WINDOW_MAXIMIZED) != 0;
|
||||
SDL_Window *win = reaktor_sdl_window(app);
|
||||
int maximised = (SDL_GetWindowFlags(win) & SDL_WINDOW_MAXIMIZED) != 0;
|
||||
struct nk_rect bar;
|
||||
|
||||
app->ctl_n = 0;
|
||||
g_ctl_n = 0;
|
||||
bar = nk_widget_bounds(ctx);
|
||||
if (!nk_group_begin(ctx, "titlebar", NK_WINDOW_NO_SCROLLBAR)) return;
|
||||
reaktor_note_push(app, REAKTOR_A11Y_GROUP, "Title bar", NULL, 0, bar);
|
||||
@@ -163,16 +206,16 @@ titlebar(App *app, struct nk_context *ctx, int win_w)
|
||||
nk_spacing(ctx, 1);
|
||||
|
||||
nk_layout_row_push(ctx, (float)MARK_SIZE);
|
||||
image_centred(ctx, icon(app, REAKTOR_MARK, MARK_SIZE), MARK_SIZE);
|
||||
image_centered(ctx, reaktor_svg(app, REAKTOR_MARK, MARK_SIZE), MARK_SIZE);
|
||||
|
||||
nk_layout_row_push(ctx, (float)(win_w - TITLE_PAD - MARK_SIZE -
|
||||
3 * CTL_SIZE - 2 * 4 - 5 * 4));
|
||||
{
|
||||
nk_style_push_font(ctx, pick_font(app, TITLE_PX, 1));
|
||||
if (app->dark && reaktor_style_token("--text-muted", c))
|
||||
nk_style_push_color(ctx, &ctx->style.text.color, col_of(c));
|
||||
nk_style_push_font(ctx, reaktor_font(app, TITLE_PX, 1));
|
||||
if (reaktor_dark(app) && reaktor_style_token("--text-muted", c))
|
||||
nk_style_push_color(ctx, &ctx->style.text.color, reaktor_col(c));
|
||||
else
|
||||
nk_style_push_color(ctx, &ctx->style.text.color, app->text);
|
||||
nk_style_push_color(ctx, &ctx->style.text.color, text_main());
|
||||
nk_style_push_vec2(ctx, &ctx->style.text.padding, nk_vec2(3.0f, 0.0f));
|
||||
reaktor_note_here(app, ctx, REAKTOR_A11Y_LABEL, "Reaktor", 0);
|
||||
nk_label(ctx, "Reaktor", NK_TEXT_LEFT);
|
||||
@@ -183,15 +226,15 @@ titlebar(App *app, struct nk_context *ctx, int win_w)
|
||||
|
||||
nk_layout_row_push(ctx, (float)CTL_SIZE);
|
||||
if (titlebar_button(app, ctx, "remove-outline", "Minimize", GLYPH_MINIMISE))
|
||||
SDL_MinimizeWindow(app->win);
|
||||
SDL_MinimizeWindow(win);
|
||||
|
||||
nk_layout_row_push(ctx, (float)CTL_SIZE);
|
||||
if (titlebar_button(app, ctx,
|
||||
maximised ? "copy-outline" : "square-outline",
|
||||
maximised ? "Restore" : "Maximize",
|
||||
GLYPH_MAXIMISE)) {
|
||||
if (maximised) SDL_RestoreWindow(app->win);
|
||||
else SDL_MaximizeWindow(app->win);
|
||||
if (maximised) SDL_RestoreWindow(win);
|
||||
else SDL_MaximizeWindow(win);
|
||||
}
|
||||
|
||||
nk_layout_row_push(ctx, (float)CTL_SIZE);
|
||||
@@ -231,28 +274,35 @@ login_card(App *app, struct nk_context *ctx, float body_x, float body_w,
|
||||
float body_y, float body_h)
|
||||
{
|
||||
struct nk_rect at;
|
||||
float card_h = card_height(app->show_contact);
|
||||
float side = body_x + (body_w - (float)CARD_W) * 0.5f;
|
||||
float card_h = g_card_h > 0.0f ? g_card_h : card_height(g_show_contact);
|
||||
float card_w = body_w - 16.0f < (float)CARD_W ? body_w - 16.0f : (float)CARD_W;
|
||||
float side = body_x + (body_w - card_w) * 0.5f;
|
||||
float top = body_y + (body_h - card_height(0)) * 0.5f;
|
||||
|
||||
if (side < body_x + 8.0f) side = body_x + 8.0f;
|
||||
|
||||
if (top + card_h > body_y + body_h - 8.0f)
|
||||
top = body_y + body_h - card_h - 8.0f;
|
||||
if (top < body_y + 8.0f) top = body_y + 8.0f;
|
||||
|
||||
nk_layout_space_push(ctx, nk_rect(side, top, (float)CARD_W, card_h));
|
||||
nk_layout_space_push(ctx, nk_rect(side, top, card_w, card_h));
|
||||
|
||||
at = nk_widget_bounds(ctx);
|
||||
|
||||
reaktor_fill_round(app, nk_window_get_canvas(ctx), at,
|
||||
ctx->style.button.rounding, app->card_bg);
|
||||
ctx->style.button.rounding,
|
||||
reaktor_token("--background", nk_rgb(226, 226, 226)));
|
||||
nk_style_push_style_item(ctx, &ctx->style.window.fixed_background,
|
||||
nk_style_item_color(nk_rgba(0, 0, 0, 0)));
|
||||
nk_style_push_vec2(ctx, &ctx->style.window.group_padding, nk_vec2(0, 0));
|
||||
if (nk_group_begin(ctx, "card", NK_WINDOW_NO_SCROLLBAR)) {
|
||||
REAKTOR_COLUMN(.name = "Proceed with login",
|
||||
.w = CARD_W, .h = card_h, .gap = ROW_GAP) {
|
||||
.w = card_w, .gap = ROW_GAP) {
|
||||
struct nk_rect laid;
|
||||
|
||||
/* The card is as tall as a sheet's margins make its rows. */
|
||||
if (reaktor_box_rect(&laid) && laid.h != g_card_h) {
|
||||
g_card_h = laid.h;
|
||||
reaktor_wake(app);
|
||||
}
|
||||
REAKTOR_ROW(.h = ROW_BRAND, .gap = 10, .flags = REAKTOR_LAY_FILL_X,
|
||||
.ml = CARD_PAD_X, .mr = CARD_PAD_X, .mt = CARD_PAD_Y) {
|
||||
reaktor_icon(&(reaktor_icon_spec){
|
||||
@@ -292,13 +342,14 @@ login_card(App *app, struct nk_context *ctx, float body_x, float body_w,
|
||||
.ml = CARD_PAD_X, .mr = CARD_PAD_X } });
|
||||
|
||||
if (reaktor_link(&(reaktor_link_spec){
|
||||
.text = app->show_contact ? "hide contact" : "contact",
|
||||
.text = g_show_contact ? "hide contact" : "contact",
|
||||
.style = ".card-link",
|
||||
.box = { .h = ROW_SMALL, .flags = REAKTOR_LAY_FILL_X,
|
||||
.ml = CARD_PAD_X, .mr = CARD_PAD_X } }))
|
||||
app->show_contact = !app->show_contact;
|
||||
.ml = CARD_PAD_X, .mr = CARD_PAD_X,
|
||||
.mb = g_show_contact ? 0.0f : CARD_PAD_Y } }))
|
||||
g_show_contact = !g_show_contact;
|
||||
|
||||
if (app->show_contact) {
|
||||
if (g_show_contact) {
|
||||
static const char *const lines[CONTACT_ROWS] = {
|
||||
"support@reaktor.example",
|
||||
"+44 20 7946 0958",
|
||||
@@ -310,7 +361,8 @@ login_card(App *app, struct nk_context *ctx, float body_x, float body_w,
|
||||
reaktor_label(&(reaktor_label_spec){
|
||||
.text = lines[i], .style = ".card-link", .align = REAKTOR_CENTRE,
|
||||
.box = { .h = ROW_SMALL, .flags = REAKTOR_LAY_FILL_X,
|
||||
.ml = CARD_PAD_X, .mr = CARD_PAD_X } });
|
||||
.ml = CARD_PAD_X, .mr = CARD_PAD_X,
|
||||
.mb = i == CONTACT_ROWS - 1 ? CARD_PAD_Y : 0.0f } });
|
||||
}
|
||||
}
|
||||
nk_group_end(ctx);
|
||||
@@ -319,7 +371,7 @@ login_card(App *app, struct nk_context *ctx, float body_x, float body_w,
|
||||
nk_style_pop_style_item(ctx);
|
||||
}
|
||||
|
||||
static style_frame
|
||||
static shell_style
|
||||
push_strip_look(struct nk_context *ctx, struct nk_color fg, struct nk_color wash)
|
||||
{
|
||||
nk_style_push_style_item(ctx, &ctx->style.button.normal,
|
||||
@@ -333,7 +385,7 @@ push_strip_look(struct nk_context *ctx, struct nk_color fg, struct nk_color wash
|
||||
nk_style_push_color(ctx, &ctx->style.button.text_active, fg);
|
||||
nk_style_push_float(ctx, &ctx->style.button.border, 0.0f);
|
||||
nk_style_push_float(ctx, &ctx->style.button.rounding, 4.0f);
|
||||
return (style_frame){ 3, 3, 2, 0, 0 };
|
||||
return (shell_style){ 3, 3, 2, 0, 0 };
|
||||
}
|
||||
|
||||
static struct nk_color
|
||||
@@ -346,9 +398,10 @@ int
|
||||
sample_option(App *app, struct nk_context *ctx, const char *label, float w,
|
||||
int on)
|
||||
{
|
||||
struct nk_color fg = reaktor_token(on ? "--links" : "--text-muted", app->text);
|
||||
struct nk_color fg = on ? reaktor_accent_color(app)
|
||||
: reaktor_token("--text-muted", text_main());
|
||||
struct nk_rect b;
|
||||
style_frame look;
|
||||
shell_style look;
|
||||
unsigned id;
|
||||
int hit;
|
||||
|
||||
@@ -359,7 +412,7 @@ sample_option(App *app, struct nk_context *ctx, const char *label, float w,
|
||||
}
|
||||
nk_layout_row_push(ctx, w);
|
||||
b = nk_widget_bounds(ctx);
|
||||
hot_push(app, b, 1, 1);
|
||||
reaktor_hot(app, b, 1, 1);
|
||||
|
||||
look = push_strip_look(ctx, fg, strip_wash());
|
||||
id = reaktor_note(app, REAKTOR_A11Y_RADIO, label, NULL,
|
||||
@@ -374,24 +427,13 @@ sample_option(App *app, struct nk_context *ctx, const char *label, float w,
|
||||
static void
|
||||
toggle_titlebar(App *app)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
if (app->borderless_lock_frames == 0) {
|
||||
app->borderless_pending = 1;
|
||||
app->dirty = 1;
|
||||
}
|
||||
#else
|
||||
app->borderless = !app->borderless;
|
||||
SDL_SetWindowBordered(app->win, app->borderless ? false : true);
|
||||
SDL_SetWindowHitTest(app->win, app->borderless ? window_hit_test : NULL,
|
||||
app->borderless ? app : NULL);
|
||||
app->ctl_n = 0;
|
||||
app->dirty = 1;
|
||||
#endif
|
||||
reaktor_set_borderless(app, !reaktor_borderless(app));
|
||||
g_ctl_n = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
nav(App *app, float w, float h)
|
||||
nav(App *app, float w, float inner_w, float h)
|
||||
{
|
||||
static const char *const icons[TAB_COUNT] = {
|
||||
"person-outline", "tablet-landscape-outline", "create-outline",
|
||||
@@ -407,7 +449,7 @@ nav(App *app, float w, float h)
|
||||
const char *key_of[TAB_COUNT];
|
||||
char all[160];
|
||||
unsigned char narrow = w < (float)NAV_W;
|
||||
int tab = sample_tab(), scheme = app->theme_mode, i;
|
||||
int tab = sample_tab(), scheme = (int)reaktor_get_theme(app), i;
|
||||
|
||||
for (i = 0; i < TAB_COUNT; i++) {
|
||||
sample_tab_keys(i, keys[i], (int)sizeof(keys[i]));
|
||||
@@ -415,16 +457,31 @@ nav(App *app, float w, float h)
|
||||
}
|
||||
sample_tablist_keys(all, (int)sizeof(all));
|
||||
|
||||
REAKTOR_FREE(.w = w, .h = h)
|
||||
REAKTOR_COLUMN(.w = w - 16.0f, .h = h - 16.0f, .ml = 8.0f, .mt = 8.0f,
|
||||
REAKTOR_FREE(.w = inner_w)
|
||||
REAKTOR_COLUMN(.w = inner_w - 16.0f, .ml = 8.0f, .mt = 8.0f, .mb = 8.0f,
|
||||
.gap = 2.0f) {
|
||||
struct nk_rect laid;
|
||||
|
||||
/* The scheme sits at the foot when the window has room for both
|
||||
* lists; when it has none, the sidebar scrolls. */
|
||||
if (reaktor_box_rect(&laid)) {
|
||||
float room = h - 16.0f - (laid.h - g_nav_room);
|
||||
int over = room < 0.0f;
|
||||
|
||||
if (over) room = 0.0f;
|
||||
if (room != g_nav_room || over != g_nav_over) {
|
||||
g_nav_room = room;
|
||||
g_nav_over = over;
|
||||
reaktor_wake(app);
|
||||
}
|
||||
}
|
||||
if (reaktor_sidebar(&(reaktor_sidebar_spec){
|
||||
.items = reaktor_tab_names, .icons = icons, .keys = key_of,
|
||||
.count = TAB_COUNT, .chosen = &tab, .name = "Pages",
|
||||
.list_keys = all, .narrow = narrow,
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X } }))
|
||||
set_tab(app, tab);
|
||||
REAKTOR_COLUMN(.flags = REAKTOR_LAY_FILL_X | REAKTOR_LAY_FILL_Y) {}
|
||||
REAKTOR_COLUMN(.h = g_nav_room, .flags = REAKTOR_LAY_FILL_X) {}
|
||||
if (reaktor_sidebar(&(reaktor_sidebar_spec){
|
||||
.items = schemes, .icons = scheme_icons, .count = 3,
|
||||
.chosen = &scheme, .name = "Color scheme",
|
||||
@@ -437,7 +494,7 @@ nav(App *app, float w, float h)
|
||||
const char *bar[1];
|
||||
int pick = -1;
|
||||
|
||||
bar[0] = app->borderless ? "Native titlebar" : "Custom titlebar";
|
||||
bar[0] = reaktor_borderless(app) ? "Native titlebar" : "Custom titlebar";
|
||||
if (reaktor_sidebar(&(reaktor_sidebar_spec){
|
||||
.items = bar, .icons = bar_icon, .count = 1, .chosen = &pick,
|
||||
.name = "Window", .kind = REAKTOR_NAV_ACTIONS,
|
||||
@@ -460,8 +517,8 @@ static void
|
||||
tray_show(App *app, int checked, void *user)
|
||||
{
|
||||
(void)checked; (void)user;
|
||||
SDL_RestoreWindow(app->win);
|
||||
SDL_RaiseWindow(app->win);
|
||||
SDL_RestoreWindow(reaktor_sdl_window(app));
|
||||
SDL_RaiseWindow(reaktor_sdl_window(app));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -519,37 +576,56 @@ showcase_tray_show(App *app, int on)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
body_metrics_push(struct nk_context *ctx, float pad_x)
|
||||
{
|
||||
nk_style_push_vec2(ctx, &ctx->style.window.group_padding,
|
||||
nk_vec2(pad_x, 12.0f));
|
||||
nk_style_push_vec2(ctx, &ctx->style.window.scrollbar_size,
|
||||
nk_vec2(ctx->style.window.scrollbar_size.x, 0.0f));
|
||||
}
|
||||
|
||||
static void
|
||||
body_metrics_pop(struct nk_context *ctx)
|
||||
{
|
||||
nk_style_pop_vec2(ctx);
|
||||
nk_style_pop_vec2(ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
page_shell(App *app, struct nk_context *ctx, int win_w, int win_h)
|
||||
{
|
||||
float top = app->borderless ? (float)TITLEBAR_H : 0.0f;
|
||||
int framed = reaktor_borderless(app);
|
||||
float top = framed ? (float)TITLEBAR_H : 0.0f;
|
||||
float nav_w = win_w < NAV_WIDE_MIN ? (float)NAV_W_NARROW : (float)NAV_W;
|
||||
float body_h = (float)win_h - top;
|
||||
struct nk_rect panel = nk_rect(nav_w, top + (app->borderless ? 0.0f : PANEL_GAP),
|
||||
struct nk_rect panel = nk_rect(nav_w, top + (framed ? 0.0f : PANEL_GAP),
|
||||
(float)win_w - nav_w - PANEL_GAP, 0.0f);
|
||||
struct nk_rect body;
|
||||
struct nk_rect body, reveal;
|
||||
struct nk_color card = reaktor_token("--background", nk_rgb(226, 226, 226));
|
||||
reaktor_theme scheme = reaktor_get_theme(app);
|
||||
|
||||
panel.h = (float)win_h - panel.y - PANEL_GAP;
|
||||
if (panel.w < 1.0f) panel.w = 1.0f;
|
||||
if (panel.h < 1.0f) panel.h = 1.0f;
|
||||
if (body_h < 1.0f) body_h = 1.0f;
|
||||
body = nk_rect(panel.x, panel.y + PANEL_R * 0.5f, panel.w, panel.h - PANEL_R);
|
||||
reaktor_tray_check(app, TRAY_SYSTEM, app->theme_mode == REAKTOR_THEME_SYSTEM);
|
||||
reaktor_tray_check(app, TRAY_LIGHT, app->theme_mode == REAKTOR_THEME_LIGHT);
|
||||
reaktor_tray_check(app, TRAY_DARK, app->theme_mode == REAKTOR_THEME_DARK);
|
||||
reaktor_tray_check(app, TRAY_SYSTEM, scheme == REAKTOR_THEME_SYSTEM);
|
||||
reaktor_tray_check(app, TRAY_LIGHT, scheme == REAKTOR_THEME_LIGHT);
|
||||
reaktor_tray_check(app, TRAY_DARK, scheme == REAKTOR_THEME_DARK);
|
||||
{
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
|
||||
nk_fill_rect(cv, nk_rect(0.0f, 0.0f, (float)win_w, (float)win_h), 0.0f,
|
||||
app->card_bg);
|
||||
reaktor_fill_round(app, cv, panel, PANEL_R, app->page);
|
||||
card);
|
||||
reaktor_fill_round(app, cv, panel, PANEL_R, reaktor_page_color(app));
|
||||
}
|
||||
|
||||
nk_layout_space_begin(ctx, NK_STATIC, (float)win_h, 3);
|
||||
|
||||
if (app->borderless) {
|
||||
if (framed) {
|
||||
nk_style_push_style_item(ctx, &ctx->style.window.fixed_background,
|
||||
nk_style_item_color(app->card_bg));
|
||||
nk_style_item_color(card));
|
||||
nk_layout_space_push(ctx, nk_rect(0, 0, (float)win_w,
|
||||
(float)TITLEBAR_H));
|
||||
titlebar(app, ctx, win_w);
|
||||
@@ -557,11 +633,11 @@ page_shell(App *app, struct nk_context *ctx, int win_w, int win_h)
|
||||
}
|
||||
|
||||
nk_style_push_style_item(ctx, &ctx->style.window.fixed_background,
|
||||
nk_style_item_color(app->card_bg));
|
||||
nk_style_item_color(card));
|
||||
nk_style_push_vec2(ctx, &ctx->style.window.group_padding, nk_vec2(0, 0));
|
||||
nk_layout_space_push(ctx, nk_rect(0, top, nav_w, body_h));
|
||||
if (nk_group_begin(ctx, "nav", NK_WINDOW_NO_SCROLLBAR)) {
|
||||
nav(app, nav_w, body_h);
|
||||
if (nk_group_begin(ctx, "nav", g_nav_over ? 0 : NK_WINDOW_NO_SCROLLBAR)) {
|
||||
nav(app, nav_w, nk_window_get_content_region_size(ctx).x, body_h);
|
||||
nk_group_end(ctx);
|
||||
}
|
||||
nk_style_pop_vec2(ctx);
|
||||
@@ -588,10 +664,9 @@ page_shell(App *app, struct nk_context *ctx, int win_w, int win_h)
|
||||
reaktor_wake(app);
|
||||
}
|
||||
}
|
||||
app->body_rect = body;
|
||||
if (app->focus_scroll) {
|
||||
if (reaktor_focus_scroll(app, &reveal)) {
|
||||
const float air = 12.0f;
|
||||
struct nk_rect r = app->focus_scroll_rect;
|
||||
struct nk_rect r = reveal;
|
||||
nk_uint sx, sy;
|
||||
float dy = 0.0f;
|
||||
|
||||
@@ -602,16 +677,12 @@ page_shell(App *app, struct nk_context *ctx, int win_w, int win_h)
|
||||
dy = r.y + r.h - (body.y + body.h - air);
|
||||
if ((float)sy + dy < 0.0f) dy = -(float)sy;
|
||||
nk_group_set_scroll(ctx, "body", sx, (nk_uint)((float)sy + dy));
|
||||
app->focus_scroll = 0;
|
||||
app->dirty = 1;
|
||||
reaktor_wake(app);
|
||||
}
|
||||
|
||||
nk_style_push_style_item(ctx, &ctx->style.window.fixed_background,
|
||||
nk_style_item_hide());
|
||||
nk_style_push_vec2(ctx, &ctx->style.window.group_padding,
|
||||
nk_vec2(20.0f, 12.0f));
|
||||
nk_style_push_vec2(ctx, &ctx->style.window.scrollbar_size,
|
||||
nk_vec2(ctx->style.window.scrollbar_size.x, 0.0f));
|
||||
body_metrics_push(ctx, BODY_PAD_X);
|
||||
if (nk_group_begin(ctx, "body", 0)) {
|
||||
struct nk_vec2 sz = nk_window_get_content_region_size(ctx);
|
||||
|
||||
@@ -622,22 +693,23 @@ page_shell(App *app, struct nk_context *ctx, int win_w, int win_h)
|
||||
nk_push_scissor(cv, nk_rect(c.x - 2.0f, c.y, c.w + 4.0f, c.h));
|
||||
}
|
||||
|
||||
nk_style_pop_vec2(ctx);
|
||||
nk_style_pop_vec2(ctx);
|
||||
body_metrics_pop(ctx);
|
||||
nk_style_pop_style_item(ctx);
|
||||
|
||||
hot_push(app, app->body_rect, 0, 0);
|
||||
reaktor_hot(app, body, 0, 0);
|
||||
|
||||
app->page_node =
|
||||
reaktor_note_push(app, REAKTOR_A11Y_GROUP,
|
||||
reaktor_tab_names[sample_tab()], NULL, 0,
|
||||
app->body_rect);
|
||||
reaktor_focus_area(app, body,
|
||||
reaktor_note_push(app, REAKTOR_A11Y_GROUP,
|
||||
reaktor_tab_names[sample_tab()],
|
||||
NULL, 0, body));
|
||||
reaktor_showcase_page(app, ctx, sample_tab(), sz.x, sz.y);
|
||||
reaktor_note_pop(app);
|
||||
/* nk_group_end sets the bar this far past the content: mid-gutter. */
|
||||
body_metrics_push(ctx, BODY_PAD_X * 0.5f);
|
||||
nk_group_end(ctx);
|
||||
body_metrics_pop(ctx);
|
||||
} else {
|
||||
nk_style_pop_vec2(ctx);
|
||||
nk_style_pop_vec2(ctx);
|
||||
body_metrics_pop(ctx);
|
||||
nk_style_pop_style_item(ctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#include "internal.h"
|
||||
#include "showcase.h"
|
||||
#include "keys.h"
|
||||
|
||||
enum {
|
||||
ACT_NEXT_PAGE = 1,
|
||||
|
||||
+639
-47
@@ -5,20 +5,14 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "nk_common.h"
|
||||
#include "ui.h"
|
||||
#include "showcase.h"
|
||||
#include "declare.h"
|
||||
#include "anim.h"
|
||||
#include "locale.h"
|
||||
#include "style.h"
|
||||
|
||||
|
||||
#define ROW 30.0f
|
||||
#define ROW_TALL 34.0f
|
||||
#define ROW_SMALL 22.0f
|
||||
|
||||
const char *const reaktor_rss_names[RSS_STEPS] = {
|
||||
static const char *const rss_names[REAKTOR_RSS_STEPS] = {
|
||||
"before any of it", "SDL_Init(VIDEO)", "window and renderer",
|
||||
"window icon", "Nuklear context", "font atlas", "stylesheets"
|
||||
};
|
||||
@@ -80,7 +74,7 @@ api(App *app, struct nk_context *ctx, const char *text)
|
||||
nk_layout_row_dynamic(ctx, 18.0f, 1);
|
||||
reaktor_note_here(app, ctx, REAKTOR_A11Y_LABEL, text, 0);
|
||||
nk_label_colored(ctx, text, NK_TEXT_LEFT,
|
||||
reaktor_token("--links", ctx->style.text.color));
|
||||
reaktor_accent_color(app));
|
||||
nk_style_pop_font(ctx);
|
||||
nk_layout_row_dynamic(ctx, 4.0f, 1);
|
||||
nk_spacer(ctx);
|
||||
@@ -145,7 +139,7 @@ draw_tooltip(App *app, struct nk_context *ctx, const char *const *lines,
|
||||
struct nk_color ink = reaktor_token("--text-main", nk_rgb(247, 247, 247));
|
||||
struct nk_color edge = reaktor_token("--text-muted",
|
||||
nk_rgb(192, 192, 192));
|
||||
struct nk_color acc = reaktor_token("--links", nk_rgb(86, 199, 255));
|
||||
struct nk_color acc = reaktor_accent_color(app);
|
||||
float pad = 10.0f, line = f->height + 6.0f;
|
||||
float w = 0.0f, h = 2.0f * pad + (float)n * line;
|
||||
struct nk_rect r;
|
||||
@@ -183,9 +177,7 @@ draw_tooltip(App *app, struct nk_context *ctx, const char *const *lines,
|
||||
if (bar >= 0.0f) {
|
||||
struct nk_rect track = nk_rect(r.x + pad, r.y + h - pad - 6.0f,
|
||||
r.w - 2.0f * pad, 6.0f);
|
||||
reaktor_fill_round(app, canvas, track, 3.0f,
|
||||
reaktor_token("--background-body",
|
||||
nk_rgb(37, 37, 37)));
|
||||
reaktor_fill_round(app, canvas, track, 3.0f, reaktor_page_color(app));
|
||||
track.w *= bar;
|
||||
reaktor_fill_round(app, canvas, track, 3.0f, acc);
|
||||
}
|
||||
@@ -233,6 +225,7 @@ seed(showcase_state *s)
|
||||
s->anim_ms = 320;
|
||||
s->anim_curve = REAKTOR_EASE_CUBIC_OUT;
|
||||
s->anim_slot = 0;
|
||||
for (i = 0; i < 4; i++) s->grow[i] = 1.0f;
|
||||
|
||||
SDL_strlcpy(s->name, "Ada Lovelace", sizeof(s->name));
|
||||
s->name_len = (int)strlen(s->name);
|
||||
@@ -679,11 +672,12 @@ page_inputs(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
int i;
|
||||
|
||||
REAKTOR_COLUMN(.gap = ctx->style.window.spacing.y) {
|
||||
REAKTOR_ROW(.h = ROW_TALL, .gap = ctx->style.window.spacing.x) {
|
||||
REAKTOR_ROW(.h = ROW_TALL, .gap = ctx->style.window.spacing.x,
|
||||
.flags = REAKTOR_LAY_FILL_X) {
|
||||
REAKTOR_COMBO(.label = sizes[s->combo_size], .name = "Size",
|
||||
.body_h = 130.0f,
|
||||
.box = { .w = 440.0f,
|
||||
.flags = REAKTOR_LAY_FILL_Y }) {
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y }) {
|
||||
nk_layout_row_dynamic(ctx, 26.0f, 1);
|
||||
for (i = 0; i < 3; i++)
|
||||
if (reaktor_combo_item(sizes[i], i == s->combo_size))
|
||||
@@ -692,21 +686,22 @@ page_inputs(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
REAKTOR_COMBO(.label = sizes[s->combo_symbol],
|
||||
.name = "Size, with a symbol",
|
||||
.body_h = 130.0f, .disc = 1,
|
||||
.box = { .w = 440.0f,
|
||||
.flags = REAKTOR_LAY_FILL_Y }) {
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y }) {
|
||||
nk_layout_row_dynamic(ctx, 26.0f, 1);
|
||||
for (i = 0; i < 3; i++)
|
||||
if (reaktor_combo_item(sizes[i], i == s->combo_symbol))
|
||||
s->combo_symbol = i;
|
||||
}
|
||||
}
|
||||
REAKTOR_ROW(.h = ROW_TALL, .gap = ctx->style.window.spacing.x) {
|
||||
REAKTOR_ROW(.h = ROW_TALL, .gap = ctx->style.window.spacing.x,
|
||||
.flags = REAKTOR_LAY_FILL_X) {
|
||||
struct nk_color tint = nk_rgb_cf(s->tint);
|
||||
|
||||
REAKTOR_COMBO(.name = "Tint", .body_h = 150.0f,
|
||||
.swatch = &tint,
|
||||
.box = { .w = 440.0f,
|
||||
.flags = REAKTOR_LAY_FILL_Y }) {
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y }) {
|
||||
nk_layout_row_dynamic(ctx, 26.0f, 1);
|
||||
reaktor_hot_follow(app, nk_widget_bounds(ctx), 0);
|
||||
nk_property_float(ctx, "R:", 0.0f, &s->tint.r, 1.0f,
|
||||
@@ -720,8 +715,8 @@ page_inputs(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
}
|
||||
REAKTOR_COMBO(.label = "Anything at all",
|
||||
.name = "Anything at all", .body_h = 130.0f,
|
||||
.box = { .w = 440.0f,
|
||||
.flags = REAKTOR_LAY_FILL_Y }) {
|
||||
.box = { .flags = REAKTOR_LAY_FILL_X |
|
||||
REAKTOR_LAY_FILL_Y }) {
|
||||
nk_layout_row_dynamic(ctx, 26.0f, 1);
|
||||
nk_label(ctx, "A combo is just a popup", NK_TEXT_LEFT);
|
||||
reaktor_slider_bar(app, ctx, 0, &s->slider_f, 0.0f, 1.0f,
|
||||
@@ -835,8 +830,8 @@ section_grid(App *app, struct nk_context *ctx)
|
||||
even = reaktor_token("--table-bg-alt", nk_rgb(37, 37, 37));
|
||||
|
||||
{
|
||||
struct nk_color page = reaktor_token("--background-body", nk_rgb(37, 37, 37));
|
||||
struct nk_color accent = reaktor_token("--links", nk_rgb(0, 112, 224));
|
||||
struct nk_color page = reaktor_page_color(app);
|
||||
struct nk_color accent = reaktor_accent_color(app);
|
||||
struct nk_color want = head_s.matched && head_s.bg[3]
|
||||
? reaktor_col(head_s.bg)
|
||||
: reaktor_token("--table", accent);
|
||||
@@ -1806,8 +1801,8 @@ ease_plot(App *app, struct nk_context *ctx, struct nk_rect slot,
|
||||
unsigned char curve, float head, int strong)
|
||||
{
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
struct nk_color line = reaktor_token(strong ? "--links" : "--text-muted",
|
||||
nk_rgb(0, 112, 224));
|
||||
struct nk_color line = strong ? reaktor_accent_color(app)
|
||||
: reaktor_token("--text-muted", nk_rgb(0, 112, 224));
|
||||
struct nk_color grid = reaktor_token("--background-hover",
|
||||
nk_rgba(128, 128, 128, 90));
|
||||
const float over = 0.28f;
|
||||
@@ -1860,29 +1855,555 @@ track_at(App *app, struct nk_context *ctx, struct nk_rect r, float where,
|
||||
+ where * (r.w - box - 2.0f * inset),
|
||||
r.y + inset, box, r.h - 2.0f * inset),
|
||||
5.0f,
|
||||
lit ? reaktor_token("--links", nk_rgb(0, 112, 224))
|
||||
lit ? reaktor_accent_color(app)
|
||||
: reaktor_token("--text-muted",
|
||||
nk_rgb(140, 140, 140)));
|
||||
}
|
||||
|
||||
static struct nk_color
|
||||
well_color(void)
|
||||
{
|
||||
return reaktor_token("--background-alt", nk_rgb(48, 48, 48));
|
||||
}
|
||||
|
||||
static struct nk_color
|
||||
well_ink(float strength)
|
||||
{
|
||||
struct nk_colorf well = nk_color_cf(well_color());
|
||||
|
||||
return nk_rgb_cf(nka_color_blend(well, nk_color_cf(reaktor_on(well_color())),
|
||||
strength, NKA_COL_OKLAB));
|
||||
}
|
||||
|
||||
static void
|
||||
well_caption(struct nk_context *ctx, struct nk_rect r, const char *text)
|
||||
{
|
||||
const struct nk_user_font *f = ctx->style.font;
|
||||
int len = (int)strlen(text);
|
||||
float w = f->width(f->userdata, f->height, text, len);
|
||||
|
||||
nk_draw_text(nk_window_get_canvas(ctx),
|
||||
nk_rect(r.x + 10.0f, r.y + r.h - f->height - 8.0f, w + 2.0f, f->height + 2.0f),
|
||||
text, len, f, nk_rgba(0, 0, 0, 0), well_ink(0.6f));
|
||||
}
|
||||
|
||||
static float
|
||||
tile_value(struct nka_context *a, nk_hash tile, nk_hash ch, float rest)
|
||||
{
|
||||
float v;
|
||||
|
||||
return nka_instance_get_float(a, tile, ch, &v) ? v : rest;
|
||||
}
|
||||
|
||||
static void
|
||||
clip_demo(App *app, struct nk_context *ctx)
|
||||
{
|
||||
const float cell = 34.0f;
|
||||
struct nka_context *a = reaktor_anim(app);
|
||||
nk_hash clip = nka_id("showcase.tiles");
|
||||
nk_hash size = nka_id("size"), fade = nka_id("fade");
|
||||
nk_hash lift = nka_id("lift"), glow = nka_id("glow");
|
||||
int i, replay = 0;
|
||||
|
||||
section(app, ctx, "One clip, every tile",
|
||||
"A clip is keyframes written once and played anywhere. Here the "
|
||||
"same four tracks - size, opacity, a lift and a glow - run on "
|
||||
"every tile in the grid, each tile starting a little after its "
|
||||
"neighbor nearer the middle, so the grid opens from the center "
|
||||
"out. The delay comes from a tile's place in the grid, not from "
|
||||
"code that knows about the others. Under it is NukAnim's own "
|
||||
"debug timeline, following the outlined tile: its tracks, its "
|
||||
"keys, which one is running and where the playhead is.");
|
||||
api(app, ctx, "nka_play_with_delay(anim, clip, tile, nka_stagger_grid_delay_index(anim, i, &grid))"
|
||||
" / nka_show_debug_timeline(anim, ctx, tile)");
|
||||
|
||||
if (!nka_clip_exists(a, clip)) {
|
||||
nka_clip_begin(a, clip);
|
||||
nka_clip_key_float(a, size, 0.0f, 0.4f, NKA_EASE_OUT_BACK, NULL);
|
||||
nka_clip_key_float(a, size, 0.5f, 1.0f, NKA_EASE_LINEAR, NULL);
|
||||
nka_clip_key_float(a, fade, 0.0f, 0.0f, NKA_EASE_OUT_CUBIC, NULL);
|
||||
nka_clip_key_float(a, fade, 0.3f, 1.0f, NKA_EASE_LINEAR, NULL);
|
||||
nka_clip_key_vec2(a, lift, 0.0f, nk_vec2(0.0f, 12.0f), NKA_EASE_OUT_CUBIC, NULL);
|
||||
nka_clip_key_vec2(a, lift, 0.45f, nk_vec2(0.0f, 0.0f), NKA_EASE_LINEAR, NULL);
|
||||
nka_clip_key_float(a, glow, 0.0f, 1.0f, NKA_EASE_IN_OUT_SINE, NULL);
|
||||
nka_clip_key_float(a, glow, 0.9f, 0.0f, NKA_EASE_LINEAR, NULL);
|
||||
nka_clip_end(a);
|
||||
}
|
||||
|
||||
REAKTOR_ROW(.h = ROW, .flags = REAKTOR_LAY_PACK_CENTER) {
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Replay", .name = "Replay the tiles",
|
||||
.box = { .w = 96.0f, .flags = REAKTOR_LAY_FILL_Y } }))
|
||||
replay = 1;
|
||||
}
|
||||
|
||||
REAKTOR_COLUMN(.gap = 6.0f) REAKTOR_ROW(.h = 4.0f * cell, .flags = REAKTOR_LAY_FILL_X) {
|
||||
struct nk_rect r;
|
||||
|
||||
if (reaktor_box_rect(&r)) {
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
struct nka_stagger_grid_opts grid = nka_stagger_grid_opts_default();
|
||||
struct nk_colorf rest = nk_color_cf(well_color());
|
||||
struct nk_colorf lit = nk_color_cf(reaktor_accent_color(app));
|
||||
int cols = (int)(r.w / cell), n;
|
||||
float x0;
|
||||
|
||||
if (cols < 1) cols = 1;
|
||||
n = cols * 4;
|
||||
x0 = r.x + (r.w - (float)cols * cell) * 0.5f;
|
||||
grid.cols = cols;
|
||||
grid.rows = 4;
|
||||
grid.from = NKA_STAGGER_CENTER;
|
||||
grid.delay = 0.6f / (float)(n - 1);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
nk_hash tile = nka_id_mix(clip, (nk_hash)i + 1u);
|
||||
float cx = x0 + ((float)(i % cols) + 0.5f) * cell;
|
||||
float cy = r.y + ((float)(i / cols) + 0.5f) * cell;
|
||||
float side = cell - 6.0f, k, alpha;
|
||||
struct nk_vec2 up = nk_vec2(0.0f, 0.0f);
|
||||
struct nk_color c;
|
||||
|
||||
if (replay)
|
||||
nka_play_with_delay(a, clip, tile, nka_stagger_grid_delay_index(a, i, &grid));
|
||||
else if (!nka_instance_valid(a, tile) && nka_play(a, clip, tile))
|
||||
nka_instance_seek(a, tile, nka_clip_duration(a, clip));
|
||||
|
||||
k = side * tile_value(a, tile, size, 1.0f);
|
||||
alpha = tile_value(a, tile, fade, 1.0f);
|
||||
nka_instance_get_vec2(a, tile, lift, &up);
|
||||
c = nk_rgb_cf(nka_color_blend(rest, lit, tile_value(a, tile, glow, 0.0f), NKA_COL_OKLAB));
|
||||
c.a = (nk_byte)(255.0f * (alpha < 0.0f ? 0.0f : alpha > 1.0f ? 1.0f : alpha) + 0.5f);
|
||||
|
||||
if (i == 0)
|
||||
reaktor_edge_round(app, cv, nk_rect(cx - side * 0.5f - 3.0f, cy - side * 0.5f - 3.0f,
|
||||
side + 6.0f, side + 6.0f),
|
||||
8.0f, 2.0f, well_ink(0.7f));
|
||||
if (c.a && k > 0.0f)
|
||||
reaktor_fill_round(app, cv, nk_rect(cx - k * 0.5f, cy - k * 0.5f + up.y, k, k),
|
||||
k * 0.2f, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nka_show_debug_timeline(a, ctx, nka_id_mix(clip, 1u));
|
||||
{
|
||||
const struct nk_panel *l = ctx->current->layout;
|
||||
|
||||
reaktor_hot_follow(app, nk_rect(l->bounds.x, l->at_y - (float)*l->offset_y,
|
||||
l->bounds.w, l->row.height), 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
build_paths(struct nka_context *a, nk_hash curve, nk_hash wave, float w, float h, float wave_h)
|
||||
{
|
||||
const float m = 24.0f;
|
||||
int i, n = (int)(w / 160.0f);
|
||||
float y = wave_h * 0.66f, amp = wave_h * 0.2f, step;
|
||||
|
||||
n = n < 2 ? 2 : n > 4 ? 4 : n;
|
||||
step = w / (float)n;
|
||||
nka_path_begin(a, curve, nk_vec2(m, h - m));
|
||||
nka_path_cubic_to(a, nk_vec2(w * 0.2f, h - m), nk_vec2(w * 0.24f, m), nk_vec2(w * 0.4f, m));
|
||||
nka_path_line_to(a, nk_vec2(w * 0.55f, m));
|
||||
nka_path_cubic_to(a, nk_vec2(w * 0.75f, m), nk_vec2(w * 0.62f, h - m), nk_vec2(w * 0.84f, h - m));
|
||||
nka_path_quadratic_to(a, nk_vec2(w - m, h - m), nk_vec2(w - m, m));
|
||||
nka_path_end(a);
|
||||
nka_path_build_arc_lut(a, curve, 0);
|
||||
|
||||
nka_path_begin(a, wave, nk_vec2(0.0f, y));
|
||||
for (i = 0; i < n; i++) {
|
||||
float x = step * (float)i, dy = i & 1 ? amp : -amp;
|
||||
|
||||
nka_path_cubic_to(a, nk_vec2(x + step * 0.36f, y + dy), nk_vec2(x + step * 0.64f, y + dy),
|
||||
nk_vec2(x + step, y));
|
||||
}
|
||||
nka_path_end(a);
|
||||
nka_path_build_arc_lut(a, wave, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
path_dots(App *app, struct nk_context *ctx, struct nka_context *a, nk_hash path, struct nk_vec2 at)
|
||||
{
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
struct nk_color ink = well_ink(0.35f);
|
||||
float len = nka_path_length(a, path), d;
|
||||
|
||||
for (d = 0.0f; d <= len; d += 12.0f) {
|
||||
struct nk_vec2 p = nka_path_evaluate_at_distance(a, path, d);
|
||||
|
||||
reaktor_fill_round(app, cv, nk_rect(at.x + p.x - 1.5f, at.y + p.y - 1.5f, 3.0f, 3.0f), 1.5f, ink);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
path_demo(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
{
|
||||
static float built_w, built_h;
|
||||
static const char words[] = "Text can follow any path you draw";
|
||||
const float wave_h = 96.0f;
|
||||
struct nka_context *a = reaktor_anim(app);
|
||||
nk_hash curve = nka_id("showcase.curve"), wave = nka_id("showcase.wave");
|
||||
nk_hash run = (nk_hash)s->path_runs;
|
||||
struct nka_ease linear = nka_ease(NKA_EASE_LINEAR);
|
||||
struct nk_rect r;
|
||||
|
||||
section(app, ctx, "Along a path",
|
||||
"A path is lines and curves joined end to end. Ridden by plain t, "
|
||||
"a dot slows wherever a curve bunches up; NukAnim measures the "
|
||||
"path once and rides it by distance, so the dot keeps one speed "
|
||||
"through bends and straights alike, and the path's direction "
|
||||
"turns it to face where it is going. The dots it passes are "
|
||||
"spaced the same way, every twelve pixels along the line. Text "
|
||||
"can travel a path too, a glyph at a time, each one standing on "
|
||||
"the line.");
|
||||
api(app, ctx, "nka_tween_path(anim, id, run, path, 2.4f, ease, 0) / nka_tween_path_angle / "
|
||||
"nka_text_path_animated(anim, ctx, path, text, t, &opts)");
|
||||
|
||||
REAKTOR_ROW(.h = ROW, .flags = REAKTOR_LAY_PACK_CENTER) {
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Send", .name = "Send the dot and the text",
|
||||
.box = { .w = 96.0f, .flags = REAKTOR_LAY_FILL_Y } }))
|
||||
s->path_runs++;
|
||||
}
|
||||
|
||||
REAKTOR_COLUMN(.gap = 6.0f) {
|
||||
REAKTOR_ROW(.h = 140.0f, .flags = REAKTOR_LAY_FILL_X) {
|
||||
if (reaktor_box_rect(&r)) {
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
unsigned id = reaktor_box_id();
|
||||
struct nk_vec2 p, tip, at = nk_vec2(r.x, r.y);
|
||||
float angle;
|
||||
|
||||
if (r.w != built_w || r.h != built_h || !nka_path_exists(a, curve)) {
|
||||
build_paths(a, curve, wave, r.w, r.h, wave_h);
|
||||
built_w = r.w;
|
||||
built_h = r.h;
|
||||
}
|
||||
reaktor_fill_round(app, cv, r, 6.0f, well_color());
|
||||
path_dots(app, ctx, a, curve, at);
|
||||
|
||||
if (run) {
|
||||
p = nka_tween_path(a, id, run, curve, 2.4f, linear, NKA_POLICY_CROSSFADE);
|
||||
angle = nka_tween_path_angle(a, id, run, curve, 2.4f, linear, NKA_POLICY_CROSSFADE);
|
||||
} else {
|
||||
p = nka_path_evaluate(a, curve, 0.0f);
|
||||
angle = nka_path_angle(a, curve, 0.0f);
|
||||
}
|
||||
p.x += at.x;
|
||||
p.y += at.y;
|
||||
tip = nk_vec2(p.x + 18.0f * cosf(angle), p.y + 18.0f * sinf(angle));
|
||||
nk_stroke_line(cv, p.x, p.y, tip.x, tip.y, 2.0f, well_ink(1.0f));
|
||||
reaktor_fill_round(app, cv, nk_rect(p.x - 8.0f, p.y - 8.0f, 16.0f, 16.0f), 8.0f,
|
||||
reaktor_accent_color(app));
|
||||
reaktor_fill_round(app, cv, nk_rect(tip.x - 3.0f, tip.y - 3.0f, 6.0f, 6.0f), 3.0f,
|
||||
well_ink(1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
REAKTOR_ROW(.h = wave_h, .flags = REAKTOR_LAY_FILL_X) {
|
||||
unsigned id = reaktor_box_id();
|
||||
float t = run ? nka_tween_float(a, id, run, 1.0f, 1.4f, linear, NKA_POLICY_CROSSFADE, 0.0f)
|
||||
: 1.0f;
|
||||
|
||||
if (reaktor_box_rect(&r) && nka_path_exists(a, wave)) {
|
||||
struct nka_text_path_opts o = nka_text_path_opts_default();
|
||||
|
||||
reaktor_fill_round(app, nk_window_get_canvas(ctx), r, 6.0f, well_color());
|
||||
path_dots(app, ctx, a, wave, nk_vec2(r.x, r.y));
|
||||
o.origin = nk_vec2(r.x, r.y);
|
||||
o.align = NKA_TEXT_ALIGN_CENTER;
|
||||
o.color = well_ink(1.0f);
|
||||
nka_text_path_animated(a, ctx, wave, words, t, &o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fx_demo(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
{
|
||||
static const char *const what[3] = { "oscillate", "wiggle", "noise" };
|
||||
struct nka_context *a = reaktor_anim(app);
|
||||
nk_hash fx = nka_id("showcase.fx"), shake = nka_id("showcase.shake");
|
||||
float on;
|
||||
int i;
|
||||
|
||||
section(app, ctx, "Motion nobody keyed",
|
||||
"Some motion has no keyframes: a bob, a drift, a tremor. "
|
||||
"Oscillate is a wave, wiggle wanders smoothly between random "
|
||||
"points, and noise reads Perlin noise along time - each one a "
|
||||
"function of the clock, so none of it needs a start or an end. "
|
||||
"They move only while Play is on, because a page at rest should "
|
||||
"draw nothing. A shake is the same idea with a decay: it starts "
|
||||
"when something goes wrong and dies out on its own. Sign in "
|
||||
"below - the password is wrong, and the field says so.");
|
||||
api(app, ctx, "nka_oscillate / nka_wiggle_vec2 / nka_noise_channel_vec2 / "
|
||||
"nka_trigger_shake + nka_shake");
|
||||
|
||||
REAKTOR_ROW(.h = ROW, .flags = REAKTOR_LAY_PACK_CENTER) {
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = s->fx_play ? "Pause" : "Play", .name = "Play the motion",
|
||||
.accent = (unsigned char)s->fx_play,
|
||||
.box = { .w = 96.0f, .flags = REAKTOR_LAY_FILL_Y } }))
|
||||
s->fx_play = !s->fx_play;
|
||||
}
|
||||
|
||||
on = nka_tween_float(a, fx, 0, s->fx_play ? 1.0f : 0.0f, 0.4f, nka_ease(NKA_EASE_OUT_CUBIC),
|
||||
NKA_POLICY_CROSSFADE, 0.0f);
|
||||
if (on <= 0.0f) s->trail_n = 0;
|
||||
|
||||
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) {
|
||||
struct nk_rect r;
|
||||
|
||||
if (reaktor_box_rect(&r)) {
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
float ax = r.w * 0.34f, ay = (r.h - 24.0f) * 0.36f;
|
||||
struct nk_vec2 c = nk_vec2(r.x + r.w * 0.5f, r.y + (r.h - 24.0f) * 0.5f);
|
||||
struct nk_vec2 d = nk_vec2(0.0f, 0.0f);
|
||||
struct nk_color dot = reaktor_accent_color(app);
|
||||
int j;
|
||||
|
||||
reaktor_fill_round(app, cv, r, 6.0f, well_color());
|
||||
well_caption(ctx, r, what[i]);
|
||||
if (i == 0)
|
||||
nk_stroke_line(cv, c.x, c.y - ay, c.x, c.y + ay, 2.0f, well_ink(0.25f));
|
||||
if (on > 0.0f) {
|
||||
nk_hash id = nka_id_mix(fx, (nk_hash)i + 1u);
|
||||
|
||||
if (i == 0) {
|
||||
d.y = nka_oscillate(a, id, ay, 0.6f, NKA_WAVE_SINE, 0.0f);
|
||||
} else if (i == 1) {
|
||||
d = nka_wiggle_vec2(a, id, nk_vec2(ax, ay), 1.4f);
|
||||
} else {
|
||||
struct nka_noise_opts o = nka_noise_opts_default();
|
||||
|
||||
o.octaves = 2;
|
||||
d = nka_noise_channel_vec2(a, id, nk_vec2(0.7f, 0.7f),
|
||||
nk_vec2(ax * 1.6f, ay * 1.6f), &o);
|
||||
d.x = d.x < -ax ? -ax : d.x > ax ? ax : d.x;
|
||||
d.y = d.y < -ay ? -ay : d.y > ay ? ay : d.y;
|
||||
}
|
||||
d.x *= on;
|
||||
d.y *= on;
|
||||
if (i == 2 && nka_time(a) - s->trail_at >= 0.035) {
|
||||
s->trail_at = nka_time(a);
|
||||
if (s->trail_n == (int)NK_LEN(s->trail)) {
|
||||
memmove(s->trail, s->trail + 1, sizeof(s->trail) - sizeof(s->trail[0]));
|
||||
s->trail_n--;
|
||||
}
|
||||
s->trail[s->trail_n++] = d;
|
||||
}
|
||||
}
|
||||
if (i == 2)
|
||||
for (j = 0; j + 1 < s->trail_n; j++) {
|
||||
float k = (float)(j + 1) / (float)s->trail_n, rad = 2.0f + 4.0f * k;
|
||||
struct nk_color t = dot;
|
||||
|
||||
t.a = (nk_byte)(160.0f * k);
|
||||
reaktor_fill_round(app, cv,
|
||||
nk_rect(c.x + s->trail[j].x - rad, c.y + s->trail[j].y - rad,
|
||||
2.0f * rad, 2.0f * rad),
|
||||
rad, t);
|
||||
}
|
||||
reaktor_fill_round(app, cv, nk_rect(c.x + d.x - 8.0f, c.y + d.y - 8.0f, 16.0f, 16.0f),
|
||||
8.0f, dot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
float dx = nka_shake(a, shake, 26.0f, 22.0f, 0.6f);
|
||||
struct nk_rect r;
|
||||
|
||||
if (reaktor_box_rect(&r)) {
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
const struct nk_style_edit *e = &ctx->style.edit;
|
||||
struct nk_rect f = nk_rect(r.x + dx, r.y, r.w, r.h);
|
||||
int j;
|
||||
|
||||
reaktor_fill_round(app, cv, f, e->rounding,
|
||||
e->normal.type == NK_STYLE_ITEM_COLOR ? e->normal.data.color : well_color());
|
||||
reaktor_edge_round(app, cv, f, e->rounding, 2.0f,
|
||||
reaktor_token("--background-hover", nk_rgb(69, 69, 69)));
|
||||
for (j = 0; j < 8; j++)
|
||||
reaktor_fill_round(app, cv, nk_rect(f.x + 14.0f + 14.0f * (float)j, f.y + f.h * 0.5f - 3.5f,
|
||||
7.0f, 7.0f),
|
||||
3.5f, e->text_normal);
|
||||
}
|
||||
}
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Sign in",
|
||||
.box = { .w = 110.0f, .flags = REAKTOR_LAY_FILL_Y } }))
|
||||
nka_trigger_shake(a, shake);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
color_demo(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
{
|
||||
static const char *const name[5] = { "sRGB", "linear", "HSV", "OKLAB", "OKLCH" };
|
||||
static const int space[5] = {
|
||||
NKA_COL_SRGB, NKA_COL_SRGB_LINEAR, NKA_COL_HSV, NKA_COL_OKLAB, NKA_COL_OKLCH
|
||||
};
|
||||
struct nka_context *a = reaktor_anim(app);
|
||||
struct nk_colorf from = nk_color_cf(nk_rgb(14, 165, 233)), to = nk_color_cf(nk_rgb(234, 88, 12));
|
||||
int i;
|
||||
|
||||
section(app, ctx, "Five ways to mix two colors",
|
||||
"Halfway from sky blue to orange is a different color depending "
|
||||
"on what gets averaged. The numbers of sRGB meet in a muddy gray, "
|
||||
"and linear light - the way light really adds - meets brighter. "
|
||||
"HSV turns the hue and passes through green. OKLAB is built so "
|
||||
"that equal steps look equal, and OKLCH turns the hue in it the "
|
||||
"other way round, through violet: each takes the short way round "
|
||||
"its own wheel, and the two wheels disagree. Each strip is one "
|
||||
"blend drawn whole, and Swap sends the swatch beside it from one "
|
||||
"end to the other through the same space.");
|
||||
api(app, ctx, "nka_color_blend(a, b, t, NKA_COL_OKLCH) / "
|
||||
"nka_tween_color(anim, id, 0, to, 1.6f, ease, NKA_POLICY_CROSSFADE, NKA_COL_OKLCH, from)");
|
||||
|
||||
REAKTOR_ROW(.h = ROW, .flags = REAKTOR_LAY_PACK_CENTER) {
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Swap", .name = "Swap the colors",
|
||||
.box = { .w = 96.0f, .flags = REAKTOR_LAY_FILL_Y } }))
|
||||
s->color_swap = !s->color_swap;
|
||||
}
|
||||
|
||||
REAKTOR_COLUMN(.gap = 6.0f) {
|
||||
for (i = 0; i < 5; i++)
|
||||
REAKTOR_ROW(.h = 34.0f, .gap = 12.0f, .flags = REAKTOR_LAY_FILL_X) {
|
||||
struct nk_rect r;
|
||||
|
||||
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) {
|
||||
if (reaktor_box_rect(&r)) {
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
int n = (int)(r.w / 4.0f), j;
|
||||
|
||||
for (j = 0; j < n; j++) {
|
||||
float x0 = r.x + (float)(int)((float)j * r.w / (float)n);
|
||||
float x1 = r.x + (float)(int)((float)(j + 1) * r.w / (float)n);
|
||||
|
||||
nk_fill_rect(cv, nk_rect(x0, r.y, x1 - x0, r.h), 0.0f,
|
||||
nk_rgb_cf(nka_color_blend(from, to, ((float)j + 0.5f) / (float)n,
|
||||
space[i])));
|
||||
}
|
||||
}
|
||||
}
|
||||
REAKTOR_ROW(.w = 64.0f, .flags = REAKTOR_LAY_FILL_Y) {
|
||||
struct nk_colorf c = nka_tween_color(a, reaktor_box_id(), 0, s->color_swap ? to : from,
|
||||
1.6f, nka_ease(NKA_EASE_IN_OUT_SINE),
|
||||
NKA_POLICY_CROSSFADE, space[i], from);
|
||||
|
||||
if (reaktor_box_rect(&r))
|
||||
reaktor_fill_round(app, nk_window_get_canvas(ctx), r, 6.0f, nk_rgb_cf(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
text_demo(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
{
|
||||
static const char *const name[5] = { "fade", "slide up", "bounce", "typewriter", "scale" };
|
||||
static const int effect[5] = {
|
||||
NKA_TEXT_FX_FADE, NKA_TEXT_FX_SLIDE_UP, NKA_TEXT_FX_BOUNCE, NKA_TEXT_FX_TYPEWRITER, NKA_TEXT_FX_SCALE
|
||||
};
|
||||
static const char line[] = "Each glyph waits its turn";
|
||||
struct nka_context *a = reaktor_anim(app);
|
||||
int i;
|
||||
|
||||
section(app, ctx, "A glyph at a time",
|
||||
"Text that arrives one letter after another reads as being said "
|
||||
"rather than shown. Every line below is the same stagger - each "
|
||||
"glyph starts a fixed time after the one before it - with a "
|
||||
"different thing done to a glyph as it arrives: faded in, slid "
|
||||
"up, overshot in size, typed, or grown.");
|
||||
api(app, ctx, "nka_text_stagger(anim, ctx, text, progress, &opts) / NKA_TEXT_FX_*");
|
||||
|
||||
REAKTOR_ROW(.h = ROW, .flags = REAKTOR_LAY_PACK_CENTER) {
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Replay", .name = "Replay the text",
|
||||
.box = { .w = 96.0f, .flags = REAKTOR_LAY_FILL_Y } }))
|
||||
s->text_plays++;
|
||||
}
|
||||
|
||||
REAKTOR_COLUMN(.gap = 6.0f) {
|
||||
for (i = 0; i < 5; i++)
|
||||
REAKTOR_ROW(.h = 34.0f, .gap = 12.0f, .flags = REAKTOR_LAY_FILL_X) {
|
||||
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) {
|
||||
struct nka_text_stagger_opts o = nka_text_stagger_opts_default();
|
||||
float t = 1.0f;
|
||||
struct nk_rect r;
|
||||
|
||||
o.effect = effect[i];
|
||||
o.char_delay = 0.035f;
|
||||
o.char_duration = 0.4f;
|
||||
o.effect_intensity = 14.0f;
|
||||
o.color = well_ink(1.0f);
|
||||
if (s->text_plays)
|
||||
t = nka_tween_float(a, reaktor_box_id(), (nk_hash)s->text_plays, 1.0f,
|
||||
nka_text_stagger_duration(line, &o), nka_ease(NKA_EASE_LINEAR),
|
||||
NKA_POLICY_CROSSFADE, 0.0f);
|
||||
if (reaktor_box_rect(&r)) {
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
struct nk_rect keep = cv->clip;
|
||||
float x0 = r.x > keep.x ? r.x : keep.x, y0 = r.y > keep.y ? r.y : keep.y;
|
||||
float x1 = r.x + r.w < keep.x + keep.w ? r.x + r.w : keep.x + keep.w;
|
||||
float y1 = r.y + r.h < keep.y + keep.h ? r.y + r.h : keep.y + keep.h;
|
||||
|
||||
reaktor_fill_round(app, cv, r, 6.0f, well_color());
|
||||
o.pos = nk_vec2(r.x + 12.0f, r.y + (r.h - ctx->style.font->height) * 0.5f);
|
||||
nk_push_scissor(cv, nk_rect(x0, y0, x1 > x0 ? x1 - x0 : 0.0f, y1 > y0 ? y1 - y0 : 0.0f));
|
||||
nka_text_stagger(a, ctx, line, t, &o);
|
||||
nk_push_scissor(cv, keep);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
page_animation(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
{
|
||||
static const float stop[3] = { 0.0f, 0.5f, 1.0f };
|
||||
static const char *const stop_name[3] = { "Left", "Center", "Right" };
|
||||
static const char *const kind[3] = { "spring", "steps", "bezier" };
|
||||
unsigned char curve = (unsigned char)s->anim_curve;
|
||||
float ms = (float)s->anim_ms;
|
||||
struct nka_ease ease[3];
|
||||
int i;
|
||||
|
||||
section(app, ctx, "The same change, twice",
|
||||
"Both blocks are told to go to the same place by the same button. "
|
||||
ease[0] = nka_ease_spring(1.0f, 170.0f, 16.0f, 0.0f);
|
||||
ease[1] = nka_ease_steps(6, 0);
|
||||
ease[2] = nka_ease_bezier(0.68f, -0.55f, 0.27f, 1.55f);
|
||||
|
||||
section(app, ctx, "The same change, five ways",
|
||||
"Every block is told to go to the same place by the same button. "
|
||||
"The top one is simply put there, which is what a frame does "
|
||||
"without help. The bottom one is given the time to travel, and "
|
||||
"the difference is the whole subject of this page: the eye "
|
||||
"follows a thing that moves and has to re-find a thing that "
|
||||
"jumps. Press one stop and then another before it arrives - it "
|
||||
"redirects from where it is rather than starting again.");
|
||||
api(app, ctx, "reaktor_animate(id, channel, to, ms, curve)");
|
||||
"without help. The rest are given the time to travel, and the "
|
||||
"difference is the whole subject of this page: the eye follows a "
|
||||
"thing that moves and has to re-find a thing that jumps. Eased "
|
||||
"runs the curve picked further down. The last three go past the "
|
||||
"classic thirty-one, with NukAnim, which runs every animation on "
|
||||
"this page: a spring that settles the way a spring does, steps "
|
||||
"that move in jumps like the hand of a clock, and whatever cubic "
|
||||
"bezier a design hands over. Press one stop and then another "
|
||||
"before they arrive - each redirects from where it is rather "
|
||||
"than starting again.");
|
||||
api(app, ctx, "reaktor_animate(id, channel, to, ms, curve) / "
|
||||
"nka_tween_float(reaktor_anim(app), id, 0, to, 0.6f, nka_ease_spring(1, 170, 16, 0), ...)");
|
||||
|
||||
REAKTOR_ROW(.h = ROW, .gap = ctx->style.window.spacing.x) {
|
||||
for (i = 0; i < 3; i++)
|
||||
@@ -1920,6 +2441,23 @@ page_animation(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
track_at(app, ctx, r, where, 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
REAKTOR_ROW(.h = 44.0f, .gap = 12.0f, .flags = REAKTOR_LAY_FILL_X) {
|
||||
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) {
|
||||
unsigned id = reaktor_box_id();
|
||||
float to = stop[s->anim_slot];
|
||||
float where = nka_tween_float(reaktor_anim(app), id, 0, to, 0.6f,
|
||||
ease[i], NKA_POLICY_CROSSFADE, to);
|
||||
struct nk_rect r;
|
||||
|
||||
if (reaktor_box_rect(&r))
|
||||
track_at(app, ctx, r, where, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
section(app, ctx, "Pick a curve by looking at it",
|
||||
@@ -1934,8 +2472,8 @@ page_animation(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
"chose, which is the value arriving.");
|
||||
api(app, ctx, "reaktor_ease_at(curve, t) / REAKTOR_EASE_*");
|
||||
|
||||
REAKTOR_ROW(.h = ROW, .gap = ctx->style.window.spacing.x,
|
||||
.flags = REAKTOR_LAY_PACK_CENTER) {
|
||||
REAKTOR_ROW(.gap = ctx->style.window.spacing.x,
|
||||
.flags = REAKTOR_LAY_PACK_CENTER | REAKTOR_LAY_WRAP) {
|
||||
unsigned id = reaktor_box_id();
|
||||
|
||||
reaktor_animate(id, 0, s->anim_play ? 1.0f : 0.0f, ms, curve);
|
||||
@@ -1944,13 +2482,12 @@ page_animation(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
if (reaktor_button(&(reaktor_button_spec){
|
||||
.label = "Play",
|
||||
.name = "Run the selected curve",
|
||||
.box = { .w = 96.0f, .flags = REAKTOR_LAY_FILL_Y } }))
|
||||
.box = { .w = 96.0f, .h = ROW } }))
|
||||
s->anim_play = !s->anim_play;
|
||||
|
||||
REAKTOR_COMBO(.label = reaktor_ease_name(curve), .name = "Curve",
|
||||
.body_h = 300.0f,
|
||||
.box = { .w = 190.0f,
|
||||
.flags = REAKTOR_LAY_FILL_Y }) {
|
||||
.box = { .w = 190.0f, .h = ROW }) {
|
||||
nk_layout_row_dynamic(ctx, 26.0f, 1);
|
||||
for (i = 0; i < REAKTOR_EASE_COUNT; i++)
|
||||
if (reaktor_combo_item(reaktor_ease_name((unsigned char)i),
|
||||
@@ -1962,7 +2499,7 @@ page_animation(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
.label = "ms:", .name = "Duration",
|
||||
.ivalue = &s->anim_ms, .lo = 60, .hi = 3000, .step = 20,
|
||||
.grain = 4.0f,
|
||||
.box = { .w = 200.0f, .flags = REAKTOR_LAY_FILL_Y } });
|
||||
.box = { .w = 200.0f, .h = ROW } });
|
||||
}
|
||||
|
||||
REAKTOR_ROW(.gap = 6.0f, .flags = REAKTOR_LAY_WRAP) {
|
||||
@@ -1987,6 +2524,58 @@ page_animation(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
}
|
||||
}
|
||||
|
||||
section(app, ctx, "Grows when you point at it",
|
||||
"A tile that rises a little under the pointer says it can be "
|
||||
"pressed before anyone presses it. Each one keeps its size in a "
|
||||
"float of its own, and nka_animate, which comes from ImAnimate, "
|
||||
"eases that float up while the pointer is over the tile and back "
|
||||
"when it leaves - from wherever it got to, so a quick pass never "
|
||||
"jumps. The color crossfades the same way, through OKLAB, where "
|
||||
"the middle of two colors still looks like both of them.");
|
||||
api(app, ctx, "nka_animate(reaktor_anim(app), 1, 1.1f, 150, &size, NKA_EASE_OUT_CUBIC)");
|
||||
|
||||
REAKTOR_COLUMN(.gap = 6.0f) REAKTOR_ROW(.h = 96.0f, .gap = 12.0f, .flags = REAKTOR_LAY_FILL_X) {
|
||||
static const char *const word[4] = { "Home", "Search", "Library", "Profile" };
|
||||
struct nka_context *anim = reaktor_anim(app);
|
||||
struct nk_command_buffer *cv = nk_window_get_canvas(ctx);
|
||||
const struct nk_user_font *f = ctx->style.font;
|
||||
struct nk_colorf rest = nk_color_cf(reaktor_token("--background-alt", nk_rgb(48, 48, 48)));
|
||||
struct nk_colorf lit = nk_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) {
|
||||
struct nk_rect r;
|
||||
|
||||
if (reaktor_box_rect(&r)) {
|
||||
int over = nk_input_is_mouse_hovering_rect(&ctx->input, r);
|
||||
int len = (int)strlen(word[i]);
|
||||
float w, h, tw;
|
||||
struct nk_color bg;
|
||||
|
||||
reaktor_hot(app, r, 0, 1);
|
||||
if (over) nka_animate(anim, 1.0f, 1.1f, 150.0f, &s->grow[i], NKA_EASE_OUT_CUBIC);
|
||||
else nka_animate(anim, 1.1f, 1.0f, 250.0f, &s->grow[i], NKA_EASE_OUT_CUBIC);
|
||||
bg = nk_rgb_cf(nka_tween_color(anim, reaktor_box_id(), 1, over ? lit : rest, 0.2f,
|
||||
nka_ease(NKA_EASE_OUT_CUBIC), NKA_POLICY_CROSSFADE,
|
||||
NKA_COL_OKLAB, rest));
|
||||
w = r.w * 0.86f * s->grow[i];
|
||||
h = r.h * 0.8f * s->grow[i];
|
||||
reaktor_fill_round(app, cv, nk_rect(r.x + (r.w - w) * 0.5f, r.y + (r.h - h) * 0.5f, w, h),
|
||||
10.0f * s->grow[i], bg);
|
||||
tw = f->width(f->userdata, f->height, word[i], len);
|
||||
nk_draw_text(cv, nk_rect(r.x + (r.w - tw) * 0.5f, r.y + (r.h - f->height) * 0.5f,
|
||||
tw + 2.0f, f->height + 2.0f),
|
||||
word[i], len, f, nk_rgba(0, 0, 0, 0), reaktor_on(bg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clip_demo(app, ctx);
|
||||
path_demo(app, ctx, s);
|
||||
fx_demo(app, ctx, s);
|
||||
color_demo(app, ctx, s);
|
||||
text_demo(app, ctx, s);
|
||||
|
||||
nk_layout_row_dynamic(ctx, 8.0f, 1);
|
||||
nk_spacer(ctx);
|
||||
}
|
||||
@@ -2262,14 +2851,17 @@ page_translations(App *app, struct nk_context *ctx, showcase_state *s)
|
||||
int i, n = reaktor_locale_count();
|
||||
struct nk_rect row;
|
||||
|
||||
nk_layout_row_begin(ctx, NK_STATIC, (float)(TAB_H - 6), n);
|
||||
nk_layout_row_begin(ctx, NK_STATIC, (float)(TAB_H - 6), n + 1);
|
||||
row = nk_widget_bounds(ctx);
|
||||
row.w = nk_window_get_content_region_size(ctx).x;
|
||||
reaktor_note_push(app, REAKTOR_A11Y_GROUP, "Language", NULL, 0, row);
|
||||
if (sample_option(app, ctx, "System", 0.0f, reaktor_locale_system()))
|
||||
reaktor_locale_set(NULL);
|
||||
for (i = 0; i < n; i++) {
|
||||
const char *code = reaktor_locale_code(i);
|
||||
|
||||
if (sample_option(app, ctx, reaktor_locale_name(i), 0.0f,
|
||||
!reaktor_locale_system() &&
|
||||
!strcmp(code, reaktor_locale_current())))
|
||||
reaktor_locale_set(code);
|
||||
}
|
||||
@@ -2445,16 +3037,16 @@ page_diagnostics(App *app, struct nk_context *ctx, showcase_state *st)
|
||||
int i;
|
||||
|
||||
SDL_snprintf(v, sizeof(v), "%.1f MB private, %.1f MB resident",
|
||||
d.priv_at[RSS_ENTRY] / 1048576.0,
|
||||
d.rss_at[RSS_ENTRY] / 1048576.0);
|
||||
d.priv_at[REAKTOR_RSS_ENTRY] / 1048576.0,
|
||||
d.rss_at[REAKTOR_RSS_ENTRY] / 1048576.0);
|
||||
DIAG_ROWS(ctx) {
|
||||
diag_row(app, ctx, reaktor_rss_names[RSS_ENTRY], v);
|
||||
for (i = RSS_ENTRY + 1; i < RSS_STEPS; i++) {
|
||||
diag_row(app, ctx, rss_names[REAKTOR_RSS_ENTRY], v);
|
||||
for (i = REAKTOR_RSS_ENTRY + 1; i < REAKTOR_RSS_STEPS; i++) {
|
||||
double dp = (d.priv_at[i] - (double)d.priv_at[i - 1]) / 1048576.0;
|
||||
double dr = (d.rss_at[i] - (double)d.rss_at[i - 1]) / 1048576.0;
|
||||
SDL_snprintf(v, sizeof(v), "%+.1f MB private %+.1f MB resident",
|
||||
dp, dr);
|
||||
diag_row(app, ctx, reaktor_rss_names[i], v);
|
||||
diag_row(app, ctx, rss_names[i], v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
#ifndef REAKTOR_SHOWCASE_H
|
||||
#define REAKTOR_SHOWCASE_H
|
||||
|
||||
#include "reaktor/launch.h"
|
||||
#include "reaktor/reaktor.h"
|
||||
|
||||
#define SC_TEXT_CAP 64
|
||||
#define SC_BOX_CAP 512
|
||||
#define SC_SERIES_N 32
|
||||
#define SC_LIST_N 64
|
||||
#define SC_PATH_CAP 520
|
||||
|
||||
#define WINDOW_WIDTH 1100
|
||||
#define WINDOW_HEIGHT 680
|
||||
|
||||
enum {
|
||||
TAB_LOGIN = 0,
|
||||
@@ -75,6 +84,12 @@ typedef struct showcase_state {
|
||||
int anim_ms;
|
||||
float anim_head;
|
||||
nk_bool anim_play;
|
||||
float grow[4];
|
||||
int path_runs, text_plays;
|
||||
nk_bool fx_play, color_swap;
|
||||
struct nk_vec2 trail[16];
|
||||
int trail_n;
|
||||
double trail_at;
|
||||
|
||||
char menu_pick[40];
|
||||
char file_pick[SC_PATH_CAP];
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#include "internal.h"
|
||||
#include "declare.h"
|
||||
#include "reaktor/launch.h"
|
||||
#include "reaktor/reaktor.h"
|
||||
#include "reaktor/main.h"
|
||||
#include "keys.h"
|
||||
|
||||
static void
|
||||
page_shell(App *app, struct nk_context *ctx, int win_w, int win_h)
|
||||
|
||||
+18
-18
@@ -41,8 +41,8 @@ enum {
|
||||
KEY_CLICK_AGAIN
|
||||
};
|
||||
|
||||
extern size_t reaktor_rss[RSS_STEPS];
|
||||
extern size_t reaktor_priv[RSS_STEPS];
|
||||
extern size_t reaktor_rss[REAKTOR_RSS_STEPS];
|
||||
extern size_t reaktor_priv[REAKTOR_RSS_STEPS];
|
||||
void reaktor_rss_mark(int step);
|
||||
|
||||
#define GLYPH_STROKE 2.0f
|
||||
@@ -124,14 +124,19 @@ struct App {
|
||||
int dragging;
|
||||
int drag_mouse;
|
||||
|
||||
int touch, touch_in_field, touch_n;
|
||||
float touch_x0, touch_y0, touch_last, touch_unit;
|
||||
float touch_ys[4];
|
||||
Uint64 touch_ns[4];
|
||||
float fling_v;
|
||||
Uint64 fling_ns;
|
||||
|
||||
int restore_rate;
|
||||
int borderless;
|
||||
#ifdef __APPLE__
|
||||
int borderless_pending;
|
||||
int borderless_lock_frames;
|
||||
#endif
|
||||
struct nk_rect ctl[3];
|
||||
int ctl_n;
|
||||
|
||||
const char *shot_path;
|
||||
const char *dump_path;
|
||||
@@ -151,12 +156,12 @@ struct App {
|
||||
int ime_valid;
|
||||
|
||||
SDL_AtomicInt file_ready, file_done;
|
||||
char file_answer[SC_PATH_CAP];
|
||||
char file_answer[520];
|
||||
int file_pending;
|
||||
|
||||
int theme_mode;
|
||||
int theme_pending;
|
||||
struct nk_color page, card_bg, text;
|
||||
struct nk_color page, card_bg, text, accent;
|
||||
char icon_hex[10];
|
||||
char accent_hex[10];
|
||||
|
||||
@@ -172,7 +177,6 @@ struct App {
|
||||
unsigned char hot_last_repaint;
|
||||
|
||||
int dirty;
|
||||
int show_contact;
|
||||
|
||||
struct input_queue {
|
||||
SDL_Event *ev;
|
||||
@@ -222,6 +226,7 @@ struct App {
|
||||
Uint64 fps_t0;
|
||||
Uint64 last_frame_ms;
|
||||
float frame_gap_ms;
|
||||
struct nka_context *anim;
|
||||
int style_ms_x100;
|
||||
int sheets;
|
||||
const char *font_face, *font_face_bold;
|
||||
@@ -231,6 +236,7 @@ struct App {
|
||||
int shot_failed, dump_failed;
|
||||
int secondary;
|
||||
int settled_run, settle_tries;
|
||||
unsigned style_gen;
|
||||
int build_ms_x100, render_ms_x100, present_ms_x100;
|
||||
};
|
||||
|
||||
@@ -242,7 +248,6 @@ void image_centred(struct nk_context *ctx, struct nk_image im, int px);
|
||||
const struct nk_user_font *pick_font(App *app, int px, int bold);
|
||||
void rebuild_font(App *app);
|
||||
void apply_render_scale(App *app);
|
||||
SDL_Surface *reaktor_icon_surface(const char *name, int px);
|
||||
void reaktor_set_window_icon(SDL_Window *win, const char *name);
|
||||
|
||||
struct nk_color col_of(const unsigned char c[4]);
|
||||
@@ -274,7 +279,7 @@ void pop_style(struct nk_context *ctx, style_frame f);
|
||||
void css_field(App *app, struct nk_context *ctx, char *buf, int *len, int cap,
|
||||
const char *hint);
|
||||
int css_button_accent(App *app, struct nk_context *ctx, const char *selector,
|
||||
const char *label, const char *token);
|
||||
const char *label, struct nk_color accent);
|
||||
int reaktor_css_button_image(App *app, struct nk_context *ctx, const char *selector,
|
||||
struct nk_image im, float px, const char *name);
|
||||
void reaktor_toasts_draw(App *app, struct nk_context *ctx, int win_w,
|
||||
@@ -301,6 +306,9 @@ reaktor_surface reaktor_rule_surface(const reaktor_style *s, float radius);
|
||||
void reaktor_paint_surface(App *app, struct nk_command_buffer *cv, struct nk_rect r,
|
||||
const reaktor_surface *s);
|
||||
struct nk_rect reaktor_rect_trunc(struct nk_rect b);
|
||||
nk_size reaktor_fade_mark(const struct nk_command_buffer *cv);
|
||||
void reaktor_fade_since(struct nk_context *ctx, const struct nk_command_buffer *cv,
|
||||
nk_size mark, float opacity);
|
||||
|
||||
App *reaktor_main_app(void);
|
||||
const char *reaktor_asset_name(const reaktor_asset *a, const char *fallback);
|
||||
@@ -321,6 +329,7 @@ void reaktor_windows_take(App *app, const SDL_Event *event);
|
||||
int reaktor_windows_retitle(App *app, const char *title);
|
||||
void reaktor_windows_draw(void);
|
||||
void reaktor_windows_restyle(void);
|
||||
void reaktor_windows_dirty(void);
|
||||
void reaktor_windows_rescale(void);
|
||||
void reaktor_windows_close_all(void);
|
||||
const char *reaktor_launch_icon(void);
|
||||
@@ -362,8 +371,6 @@ void note_ime_caret(App *app, struct nk_context *ctx, struct nk_rect bounds,
|
||||
void draw_hint(struct nk_context *ctx, struct nk_rect bounds, const char *hint,
|
||||
const reaktor_style *s);
|
||||
|
||||
struct nk_image reaktor_ionicon_exact(App *app, const char *name, int px,
|
||||
struct nk_color stroke, float sw);
|
||||
struct nk_image reaktor_ionicon_col(App *app, const char *name, int px,
|
||||
struct nk_color stroke);
|
||||
|
||||
@@ -373,8 +380,6 @@ void reaktor_image(App *app, struct nk_context *ctx, struct nk_image im,
|
||||
int reaktor_fit_label(App *app, struct nk_context *ctx, struct nk_rect b);
|
||||
void reaktor_unfit_label(struct nk_context *ctx, int fitted);
|
||||
|
||||
void reaktor_glyph_at(App *app, struct nk_context *ctx, struct nk_rect slot,
|
||||
const char *name, struct nk_color col, int px, float sw);
|
||||
#define REAKTOR_DISC_ROUND "ellipse"
|
||||
#define REAKTOR_DISC_RING "radio-button-off"
|
||||
#define REAKTOR_DISC_OUTLINE "ellipse-outline"
|
||||
@@ -398,14 +403,9 @@ 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_button_icon(App *app, struct nk_context *ctx,
|
||||
const char *ionicon, const char *label);
|
||||
int reaktor_button_color(App *app, struct nk_context *ctx, const char *name,
|
||||
struct nk_color fill);
|
||||
|
||||
nk_flags reaktor_field_text(App *app, struct nk_context *ctx, nk_flags flags,
|
||||
char *buf, int *len, int cap, const char *hint,
|
||||
nk_plugin_filter filter, float pad_x, float pad_y);
|
||||
void field_undo_clear(App *app);
|
||||
|
||||
int reaktor_focus_step(App *app, unsigned id);
|
||||
|
||||
@@ -3,131 +3,6 @@
|
||||
|
||||
#include "nk_common.h"
|
||||
#include "a11y.h"
|
||||
|
||||
#ifndef REAKTOR_APP_FWD
|
||||
#define REAKTOR_APP_FWD
|
||||
typedef struct App App;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
RSS_ENTRY,
|
||||
RSS_SDL,
|
||||
RSS_WINDOW,
|
||||
RSS_ICON,
|
||||
RSS_NUKLEAR,
|
||||
RSS_FONT,
|
||||
RSS_STYLE,
|
||||
RSS_STEPS
|
||||
};
|
||||
extern const char *const reaktor_rss_names[RSS_STEPS];
|
||||
|
||||
#define SC_TEXT_CAP 64
|
||||
#define SC_BOX_CAP 512
|
||||
#define SC_SERIES_N 32
|
||||
#define SC_LIST_N 64
|
||||
#define SC_PATH_CAP 520
|
||||
|
||||
struct nk_color reaktor_col(const unsigned char rgba[4]);
|
||||
struct nk_color reaktor_token(const char *name,
|
||||
struct nk_color def);
|
||||
struct nk_color reaktor_visible(struct nk_color want,
|
||||
struct nk_color behind,
|
||||
struct nk_color fallback);
|
||||
const struct nk_user_font *reaktor_font(App *app, int px, int bold);
|
||||
|
||||
struct nk_image reaktor_ionicon(App *app, const char *name, int px);
|
||||
|
||||
void reaktor_fill_round(App *app, struct nk_command_buffer *cv,
|
||||
struct nk_rect b, float rounding, struct nk_color col);
|
||||
void reaktor_edge_round(App *app, struct nk_command_buffer *cv,
|
||||
struct nk_rect b, float rounding, float width,
|
||||
struct nk_color col);
|
||||
struct nk_color reaktor_on(struct nk_color bg);
|
||||
|
||||
void reaktor_hot(App *app, struct nk_rect r, int cursor, int repaint);
|
||||
void reaktor_hot_top(App *app, struct nk_rect r, int cursor, int repaint);
|
||||
void reaktor_hot_follow(App *app, struct nk_rect r, int cursor);
|
||||
|
||||
int reaktor_button_label(App *app, struct nk_context *ctx, const char *label);
|
||||
void reaktor_slider_bar(App *app, struct nk_context *ctx, unsigned id,
|
||||
float *val, float lo, float hi, float step);
|
||||
|
||||
void reaktor_progress_bar(App *app, struct nk_context *ctx, nk_size *cur,
|
||||
nk_size max, int modifiable);
|
||||
|
||||
void reaktor_chevron_at(App *app, struct nk_context *ctx, struct nk_rect slot,
|
||||
const char *name, struct nk_color col);
|
||||
|
||||
int reaktor_button_accent(App *app, struct nk_context *ctx, const char *label);
|
||||
const struct nk_user_font *reaktor_style_font(App *app,
|
||||
const char *selector,
|
||||
int px, int bold);
|
||||
float reaktor_popup_rounding(void);
|
||||
|
||||
#define REAKTOR_MENU_ROW 22.0f
|
||||
#define REAKTOR_MENU_GAP 2.0f
|
||||
void reaktor_menu_style_push(struct nk_context *ctx);
|
||||
void reaktor_menu_style_pop(struct nk_context *ctx);
|
||||
float reaktor_menu_height(int rows);
|
||||
void reaktor_menu_edge(App *app, struct nk_context *ctx);
|
||||
typedef struct reaktor_toast_spec {
|
||||
const char *text;
|
||||
const char *icon;
|
||||
const char *action;
|
||||
void (*on_action)(App *app, void *user);
|
||||
void (*content)(App *app, struct nk_context *ctx, void *user);
|
||||
float content_w;
|
||||
void *user;
|
||||
int timeout_ms;
|
||||
int no_close;
|
||||
} reaktor_toast_spec;
|
||||
|
||||
/* Main thread; hooks get the main window's App. */
|
||||
void reaktor_toast(App *app, const reaktor_toast_spec *spec);
|
||||
|
||||
int reaktor_menu_item(App *app, struct nk_context *ctx, const char *label,
|
||||
const char *accel, int contextual);
|
||||
|
||||
unsigned reaktor_note(App *app, unsigned char role, const char *name,
|
||||
const char *value, unsigned state,
|
||||
struct nk_rect bounds);
|
||||
unsigned reaktor_note_push(App *app, unsigned char role, const char *name,
|
||||
const char *value, unsigned state,
|
||||
struct nk_rect bounds);
|
||||
void reaktor_note_pop(App *app);
|
||||
|
||||
int reaktor_focus_activated(App *app, unsigned id);
|
||||
|
||||
void reaktor_note_keys(App *app, unsigned id, const char *keys);
|
||||
void reaktor_note_value(App *app, unsigned id, const char *value);
|
||||
void reaktor_note_bounds(App *app, unsigned id, struct nk_rect r);
|
||||
unsigned reaktor_note_here(App *app, struct nk_context *ctx,
|
||||
unsigned char role, const char *name,
|
||||
unsigned state);
|
||||
|
||||
int reaktor_file_open(App *app);
|
||||
|
||||
typedef struct reaktor_diag {
|
||||
const char *renderer;
|
||||
const char *mode;
|
||||
const char *frame_rate;
|
||||
const char *drag_rate;
|
||||
const char *font;
|
||||
int vsync, dark, sheets;
|
||||
const char *aa;
|
||||
float scale, style_ms, build_ms, render_ms, present_ms;
|
||||
float frame_gap_ms;
|
||||
float cpu_ms_per_frame;
|
||||
int hover_gap_ms;
|
||||
unsigned long nk_bytes, nk_used, icon_bytes;
|
||||
unsigned long rss_bytes, private_bytes;
|
||||
int icons;
|
||||
int atlas_w, atlas_h, atlas_bpp;
|
||||
unsigned long rss_at[RSS_STEPS];
|
||||
unsigned long priv_at[RSS_STEPS];
|
||||
} reaktor_diag;
|
||||
|
||||
void reaktor_diagnostics(App *app, reaktor_diag *out);
|
||||
|
||||
#include "reaktor/ui.h"
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<string>@PROJECT_VERSION@</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<string>@PROJECT_VERSION@</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.13</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
|
||||
+76
-39
@@ -5,6 +5,7 @@
|
||||
#include "anim.h"
|
||||
|
||||
static int g_fail;
|
||||
static int g_moving;
|
||||
|
||||
static void
|
||||
ok(const char *what, int cond)
|
||||
@@ -13,16 +14,30 @@ ok(const char *what, int cond)
|
||||
if (!cond) g_fail = 1;
|
||||
}
|
||||
|
||||
static int
|
||||
advance(float ms)
|
||||
/* A frame of a page that shows one value: time moves, the page asks, the runtime settles. */
|
||||
static float
|
||||
frame(struct nka_context *a, unsigned id, unsigned channel, float to, float ms,
|
||||
unsigned char curve, float gap_ms)
|
||||
{
|
||||
int moving = 0;
|
||||
while (ms > 0.0f) {
|
||||
float step = ms > 16.0f ? 16.0f : ms;
|
||||
moving = reaktor_anim_tick(step);
|
||||
ms -= step;
|
||||
float v;
|
||||
reaktor_anim_frame(a, gap_ms);
|
||||
v = reaktor_animate(id, channel, to, ms, curve);
|
||||
g_moving = reaktor_anim_settle();
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Frames 16 ms apart until total has passed. */
|
||||
static float
|
||||
frames(struct nka_context *a, unsigned id, unsigned channel, float to, float ms,
|
||||
unsigned char curve, float total)
|
||||
{
|
||||
float v = 0.0f;
|
||||
while (total > 0.0f) {
|
||||
float step = total > 16.0f ? 16.0f : total;
|
||||
v = frame(a, id, channel, to, ms, curve, step);
|
||||
total -= step;
|
||||
}
|
||||
return moving;
|
||||
return v;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -109,63 +124,85 @@ static void
|
||||
test_table(void)
|
||||
{
|
||||
const unsigned id = 4242u;
|
||||
const unsigned char lin = REAKTOR_EASE_LINEAR;
|
||||
struct nka_context *a = reaktor_anim_create();
|
||||
float v;
|
||||
int n;
|
||||
|
||||
puts("");
|
||||
puts("a value starts where it is asked to, not at zero");
|
||||
v = reaktor_animate(id, 0, 0.75f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
v = frame(a, id, 0, 0.75f, 200.0f, lin, 16.0f);
|
||||
ok("the first sight of it is its target", near(v, 0.75f));
|
||||
ok("and nothing is moving", advance(16.0f) == 0);
|
||||
ok("and nothing is moving", !g_moving);
|
||||
|
||||
puts("");
|
||||
puts("a new target starts a run, and the run ends");
|
||||
v = reaktor_animate(id, 0, 0.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
v = frame(a, id, 0, 0.0f, 200.0f, lin, 0.0f);
|
||||
ok("the frame that asks still sees the old value", near(v, 0.75f));
|
||||
ok("something is moving now", advance(100.0f) == 1);
|
||||
v = reaktor_animate(id, 0, 0.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
ok("half way through a linear run is half way there",
|
||||
near(v, 0.375f));
|
||||
ok("the step that lands asks for the frame that shows it",
|
||||
advance(100.0f) == 1);
|
||||
ok("then nothing is moving", advance(16.0f) == 0);
|
||||
v = reaktor_animate(id, 0, 0.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
ok("and it arrives exactly", near(v, 0.0f));
|
||||
ok("something is moving now", g_moving);
|
||||
v = frames(a, id, 0, 0.0f, 200.0f, lin, 100.0f);
|
||||
ok("half way through a linear run is half way there", near(v, 0.375f));
|
||||
ok("and the dot on its curve says so", near(reaktor_anim_progress(id, 0), 0.5f));
|
||||
v = frames(a, id, 0, 0.0f, 200.0f, lin, 100.0f);
|
||||
ok("the frame that lands shows it arrived exactly", near(v, 0.0f));
|
||||
ok("and asks for no more", !g_moving && reaktor_anim_progress(id, 0) < 0.0f);
|
||||
|
||||
puts("");
|
||||
puts("a target that changes mid-flight redirects rather than restarts");
|
||||
reaktor_animate(id, 0, 1.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
advance(100.0f);
|
||||
v = reaktor_animate(id, 0, 1.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
frame(a, id, 0, 1.0f, 200.0f, lin, 0.0f);
|
||||
v = frames(a, id, 0, 1.0f, 200.0f, lin, 100.0f);
|
||||
ok("half way to 1", near(v, 0.5f));
|
||||
reaktor_animate(id, 0, 0.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
advance(100.0f);
|
||||
v = reaktor_animate(id, 0, 0.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
frame(a, id, 0, 0.0f, 200.0f, lin, 0.0f);
|
||||
v = frames(a, id, 0, 0.0f, 200.0f, lin, 100.0f);
|
||||
ok("and half way back from there, not from the end", near(v, 0.25f));
|
||||
|
||||
puts("");
|
||||
puts("a channel is a separate value on the same widget");
|
||||
reaktor_animate(id, 1, 10.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
v = reaktor_animate(id, 1, 10.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
v = frame(a, id, 1, 10.0f, 200.0f, lin, 16.0f);
|
||||
ok("channel 1 starts at its own target", near(v, 10.0f));
|
||||
v = reaktor_animate(id, 0, 0.0f, 200.0f, REAKTOR_EASE_LINEAR);
|
||||
ok("and channel 0 is where it was left", near(v, 0.25f));
|
||||
reaktor_anim_frame(a, 0.0f);
|
||||
v = reaktor_animate(id, 0, 0.0f, 200.0f, lin);
|
||||
ok("and channel 0 is still on its way", v > 0.0f && v < 0.25f);
|
||||
|
||||
puts("");
|
||||
puts("a long gap between frames does not teleport a run");
|
||||
{
|
||||
float start = reaktor_animate(id, 0, 1.0f, 1000.0f,
|
||||
REAKTOR_EASE_LINEAR);
|
||||
float start = frame(a, id, 0, 1.0f, 1000.0f, lin, 16.0f);
|
||||
|
||||
reaktor_anim_tick(5000.0f);
|
||||
v = reaktor_animate(id, 0, 1.0f, 1000.0f, REAKTOR_EASE_LINEAR);
|
||||
v = frame(a, id, 0, 1.0f, 1000.0f, lin, 5000.0f);
|
||||
ok("five seconds of sleep move it forward", v > start);
|
||||
ok("...by one capped step, not by all five seconds",
|
||||
v - start < 0.10f);
|
||||
ok("and the run is still going", advance(16.0f) == 1);
|
||||
ok("it does finish, given the frames", advance(1000.0f) == 0);
|
||||
v = reaktor_animate(id, 0, 1.0f, 1000.0f, REAKTOR_EASE_LINEAR);
|
||||
ok("...by one capped step, not by all five seconds", v - start < 0.10f);
|
||||
ok("and the run is still going", g_moving);
|
||||
for (n = 0; g_moving && n < 200; n++)
|
||||
v = frame(a, id, 0, 1.0f, 1000.0f, lin, 16.0f);
|
||||
ok("it does finish, given the frames", !g_moving && n < 200);
|
||||
ok("exactly where it was sent", near(v, 1.0f));
|
||||
}
|
||||
|
||||
puts("");
|
||||
puts("a settled value holds still when only its curve changes");
|
||||
v = frame(a, id, 0, 1.0f, 300.0f, REAKTOR_EASE_BOUNCE_OUT, 16.0f);
|
||||
ok("it stays where it is", near(v, 1.0f) && !g_moving);
|
||||
ok("with no dot running on its curve", reaktor_anim_progress(id, 0) < 0.0f);
|
||||
frame(a, id, 0, 0.0f, 300.0f, REAKTOR_EASE_BOUNCE_OUT, 0.0f);
|
||||
v = frames(a, id, 0, 0.0f, 300.0f, REAKTOR_EASE_BOUNCE_OUT, 150.0f);
|
||||
ok("and the next run takes the new curve",
|
||||
near(v, 1.0f - reaktor_ease_at(REAKTOR_EASE_BOUNCE_OUT, 0.5f)));
|
||||
|
||||
puts("");
|
||||
puts("each window has a table of its own");
|
||||
{
|
||||
struct nka_context *b = reaktor_anim_create();
|
||||
|
||||
v = frame(b, id, 0, 42.0f, 200.0f, lin, 16.0f);
|
||||
ok("the same id starts afresh in another", near(v, 42.0f));
|
||||
v = frame(a, id, 0, 0.0f, 300.0f, REAKTOR_EASE_BOUNCE_OUT, 0.0f);
|
||||
ok("and the first one is left as it was", v > 0.0f && v < 1.0f);
|
||||
reaktor_anim_destroy(b);
|
||||
}
|
||||
reaktor_anim_destroy(a);
|
||||
ok("a destroyed table leaves reaktor_animate answering its target",
|
||||
near(reaktor_animate(id, 0, 3.0f, 200.0f, lin), 3.0f));
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cssflat.h"
|
||||
|
||||
static int g_fail;
|
||||
|
||||
static const char g_sheet[] =
|
||||
"input: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); "
|
||||
"margin: calc(2 * (3px + 1px)); width: calc(100% - 2 * 8px); }\n";
|
||||
|
||||
char *
|
||||
reaktor_asset_load(const char *name, size_t *len)
|
||||
{
|
||||
char *out = NULL;
|
||||
long n = 0;
|
||||
|
||||
if (strcmp(name, "test.css") == 0) {
|
||||
n = (long)strlen(g_sheet);
|
||||
out = malloc((size_t)n + 1);
|
||||
if (out) memcpy(out, g_sheet, (size_t)n + 1);
|
||||
} else {
|
||||
FILE *f = fopen(name, "rb");
|
||||
|
||||
if (!f) return NULL;
|
||||
fseek(f, 0, SEEK_END);
|
||||
n = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
out = n >= 0 ? malloc((size_t)n + 1) : NULL;
|
||||
if (out && fread(out, 1, (size_t)n, f) == (size_t)n) {
|
||||
out[n] = 0;
|
||||
} else {
|
||||
free(out);
|
||||
out = NULL;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
if (out && len) *len = (size_t)n;
|
||||
return out;
|
||||
}
|
||||
|
||||
static void
|
||||
ok(const char *what, int got)
|
||||
{
|
||||
if (!got) g_fail++;
|
||||
printf(" %-52s %s\n", what, got ? "ok" : "FAILED");
|
||||
}
|
||||
|
||||
static int
|
||||
not_twice(const char *css)
|
||||
{
|
||||
const char *p = css, *q;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
static const char *const test[1] = { "test.css" };
|
||||
static const char *const simple[1] = { "external/simplecss/simple.css" };
|
||||
char *out;
|
||||
int i;
|
||||
|
||||
out = reaktor_css_flatten(test, 1, "light", 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);
|
||||
free(out);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
out = reaktor_css_flatten(simple, 1, i ? "dark" : "light", 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);
|
||||
}
|
||||
|
||||
printf("\n%s\n", g_fail ? "FAILED" : "css: all checks passed");
|
||||
return g_fail ? 1 : 0;
|
||||
}
|
||||
@@ -57,6 +57,15 @@ const int reaktor_locale_catalog_count =
|
||||
|
||||
static int failures;
|
||||
|
||||
/* locale_runtime.c asks SDL; the test answers for it. */
|
||||
static const char *g_system_code = "en";
|
||||
|
||||
const char *
|
||||
reaktor_locale_system_code(void)
|
||||
{
|
||||
return g_system_code;
|
||||
}
|
||||
|
||||
static void
|
||||
check(const char *what, long got, long want)
|
||||
{
|
||||
@@ -220,8 +229,17 @@ catalogs(void)
|
||||
check("codepoints include the kanji in the language name", has_ni, 1);
|
||||
check("codepoints leave out Latin-1", has_o, 0);
|
||||
|
||||
g_system_code = "pl";
|
||||
check("NULL follows the system", reaktor_locale_set(NULL), 1);
|
||||
check_str("to the system's language", reaktor_locale_current(), "pl");
|
||||
check("and says it follows", reaktor_locale_system(), 1);
|
||||
check("a code stops following",
|
||||
reaktor_locale_set("ja") && !reaktor_locale_system(), 1);
|
||||
reaktor_locale_set(NULL);
|
||||
|
||||
check("init again reloads cleanly", reaktor_locale_init(), 3);
|
||||
check_str("and forgets the current catalog", reaktor_locale_current(), "");
|
||||
check("and stops following", reaktor_locale_system(), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
execute_process(COMMAND "${AR}" -M INPUT_FILE "${MRI}" RESULT_VARIABLE _rc)
|
||||
if(_rc)
|
||||
message(FATAL_ERROR "merging the archives failed: ${_rc}")
|
||||
endif()
|
||||
@@ -0,0 +1,9 @@
|
||||
prefix=${pcfiledir}/../..
|
||||
includedir=${prefix}/include
|
||||
libdir=${prefix}/lib
|
||||
|
||||
Name: reaktor
|
||||
Description: A Nuklear-powered GUI library for C
|
||||
Version: @PROJECT_VERSION@
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -lreaktor @REAKTOR_PC_LIBS@
|
||||
@@ -0,0 +1,12 @@
|
||||
get_filename_component(_reaktor_prefix "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
|
||||
if(NOT TARGET reaktor::reaktor)
|
||||
add_library(reaktor::reaktor STATIC IMPORTED)
|
||||
set_target_properties(reaktor::reaktor PROPERTIES
|
||||
IMPORTED_LOCATION "${_reaktor_prefix}/lib/@REAKTOR_LIB_NAME@"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_reaktor_prefix}/include"
|
||||
INTERFACE_LINK_LIBRARIES "@REAKTOR_LINK_LIBS@"
|
||||
INTERFACE_LINK_DIRECTORIES "@REAKTOR_LINK_DIRS@"
|
||||
INTERFACE_LINK_OPTIONS "@REAKTOR_LINK_OPTIONS@")
|
||||
endif()
|
||||
unset(_reaktor_prefix)
|
||||
@@ -23,8 +23,6 @@
|
||||
display: block;
|
||||
outline: none;
|
||||
|
||||
border-radius: 10px 10px 0 0;
|
||||
|
||||
transform: translate3d(0, 0, 0);
|
||||
image-rendering: pixelated;
|
||||
image-rendering: crisp-edges;
|
||||
|
||||
Reference in New Issue
Block a user