Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84e45229ea | ||
|
|
b748fd9984 | ||
|
|
965ee181b5 | ||
|
|
1f67384eba | ||
|
|
4f9f322a33 | ||
|
|
6d009d1ad5 | ||
|
|
468c6e2d1c | ||
|
|
e6c0b85601 | ||
|
|
68f16bb0e4 | ||
|
|
5f08f33872 | ||
|
|
36f3c4fdc5 |
@@ -5,12 +5,20 @@ on:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
type: string
|
||||
default: ''
|
||||
strict:
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
group: bsd-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
@@ -18,7 +26,7 @@ jobs:
|
||||
name: ${{ matrix.os }} ${{ matrix.version }} ${{ matrix.arch }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: ${{ matrix.timeout }}
|
||||
continue-on-error: ${{ matrix.arch == 'arm64' }}
|
||||
continue-on-error: ${{ matrix.arch == 'arm64' && !inputs.strict }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -151,6 +159,52 @@ jobs:
|
||||
export PATH
|
||||
cmake --build build --target mkicon </dev/null
|
||||
|
||||
- name: Package
|
||||
id: package
|
||||
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="reaktor-${version#v}-${{ matrix.os }}-${{ matrix.arch }}"
|
||||
sh tools/package.sh build "dist/$name"
|
||||
mkdir -p check
|
||||
for from in "built build" "packed dist/$name"; do
|
||||
set -- $from
|
||||
dbus-run-session -- "$2/showcase" --tab 8 --theme light --video dummy \
|
||||
--shot "check/$1.bmp" --a11y-dump "check/$1.txt" </dev/null
|
||||
done
|
||||
for e in bmp txt; do
|
||||
cmp "check/built.$e" "check/packed.$e"
|
||||
done
|
||||
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
|
||||
@@ -161,6 +215,24 @@ jobs:
|
||||
done
|
||||
rm -rf build
|
||||
|
||||
- name: Upload the package
|
||||
if: ${{ !cancelled() && steps.package.outcome == 'success' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-${{ matrix.os }}-${{ matrix.arch }}
|
||||
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
|
||||
|
||||
- name: Upload the shots
|
||||
if: ${{ always() && steps.vm.outcome == 'success' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
|
||||
@@ -163,7 +163,40 @@ 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: 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
|
||||
|
||||
|
||||
@@ -126,7 +126,38 @@ 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: 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
|
||||
|
||||
|
||||
@@ -24,6 +24,17 @@ jobs:
|
||||
version: ${{ github.ref_name }}
|
||||
strict: true
|
||||
|
||||
bsd:
|
||||
uses: ./.github/workflows/bsd.yml
|
||||
with:
|
||||
version: ${{ github.ref_name }}
|
||||
strict: true
|
||||
|
||||
web:
|
||||
uses: ./.github/workflows/web.yml
|
||||
with:
|
||||
version: ${{ github.ref_name }}
|
||||
|
||||
source:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
@@ -47,7 +58,7 @@ jobs:
|
||||
retention-days: 14
|
||||
|
||||
publish:
|
||||
needs: [windows, macos, linux, source]
|
||||
needs: [windows, macos, linux, bsd, web, source]
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -70,11 +81,16 @@ jobs:
|
||||
| Windows | x64, x86, ARM64 | \`reaktor-$v-windows-<arch>.zip\` |
|
||||
| macOS | Apple silicon (arm64), Intel (x86_64) | \`reaktor-$v-macos-<arch>.zip\` |
|
||||
| Linux | x86-64, x86, ARM64, ARMv7 (armhf), RISC-V 64 | \`reaktor-$v-linux-<arch>.tar.gz\` |
|
||||
| FreeBSD 15.1 | x86-64, ARM64 | \`reaktor-$v-freebsd-<arch>.tar.gz\` |
|
||||
| OpenBSD 7.9 | x86-64, ARM64 | \`reaktor-$v-openbsd-<arch>.tar.gz\` |
|
||||
| NetBSD 11.0 | x86-64, ARM64 | \`reaktor-$v-netbsd-<arch>.tar.gz\` |
|
||||
| Web | WebAssembly | \`reaktor-$v-web.zip\` |
|
||||
| Source | every submodule included | \`reaktor-$v-source.tar.gz\` |
|
||||
|
||||
Each package holds the showcase, Notepad, Simple and the bench, the files
|
||||
they read at runtime, and every license (\`licenses/\`, \`NOTICE.md\`).
|
||||
Unpack it anywhere and run \`showcase\`; it finds its files beside itself.
|
||||
Each native package holds the showcase, Notepad, Simple and the bench,
|
||||
the files they read at runtime, and every license (\`licenses/\`,
|
||||
\`NOTICE.md\`). Unpack it anywhere and run \`showcase\`; it finds its files
|
||||
beside itself.
|
||||
|
||||
- **Windows**: the C runtime is linked in, so there is nothing to install.
|
||||
The programs are not signed, and SmartScreen may ask before the first run.
|
||||
@@ -82,11 +98,36 @@ jobs:
|
||||
notarized: open it from its context menu the first time.
|
||||
- **Linux**: glibc 2.36 or newer (2.41 for RISC-V), libdbus-1, and X11 or
|
||||
Wayland.
|
||||
- **Web**: the same showcase runs at https://alpaq92.github.io/Reaktor/.
|
||||
- **BSDs**: the release named above, the dbus package, and X11.
|
||||
- **Web**: the showcase, Notepad and Simple as \`.html\`, \`.js\`, \`.wasm\`
|
||||
and \`.data\`. Serve the folder over HTTP (a \`file://\` page cannot fetch
|
||||
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, mojibake and kb_text_shape inside it,
|
||||
the public headers (\`#include "reaktor/reaktor.h"\`, with Nuklear's and
|
||||
SDL's), a CMake package and a pkg-config file, and the licenses.
|
||||
|
||||
\`\`\`cmake
|
||||
find_package(reaktor 0.2 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
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
name: Web
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
type: string
|
||||
default: ''
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: web-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
web:
|
||||
name: web
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 60
|
||||
env:
|
||||
EMSCRIPTEN_VERSION: 6.0.9
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
submodules: recursive
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install emsdk
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
||||
"$HOME/emsdk/emsdk" install "$EMSCRIPTEN_VERSION"
|
||||
"$HOME/emsdk/emsdk" activate "$EMSCRIPTEN_VERSION"
|
||||
sudo apt-get update && sudo apt-get install -y ninja-build
|
||||
|
||||
- name: Build
|
||||
run: EMSDK="$HOME/emsdk" ./build-wasm.sh
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
version='${{ inputs.version || 'dev' }}'
|
||||
name="reaktor-${version#v}-web"
|
||||
mkdir -p "dist/$name/licenses"
|
||||
for p in showcase notepad simple; do
|
||||
cp "build-wasm/$p.html" "build-wasm/$p.js" "build-wasm/$p.wasm" \
|
||||
"build-wasm/$p.data" "dist/$name/"
|
||||
done
|
||||
cp build-wasm/keylog.js build-wasm/reaktor-icon.svg build-wasm/reaktor-icon.png \
|
||||
"dist/$name/"
|
||||
cp build-wasm/licenses/*.txt "dist/$name/licenses/"
|
||||
cp external/simplecss/LICENSE "dist/$name/licenses/simplecss.txt"
|
||||
cp assets/fonts/Aileron-Notice.txt assets/fonts/MPLUS1p-Notice.txt \
|
||||
"dist/$name/licenses/"
|
||||
cp docs/NOTICE.md "dist/$name/"
|
||||
(cd dist && zip -qr "$name.zip" "$name")
|
||||
|
||||
- name: Upload the package
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: package-web
|
||||
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
|
||||
@@ -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,8 @@ build-wasm/
|
||||
build-x64/
|
||||
build-x86/
|
||||
build-arm64/
|
||||
build-lib/
|
||||
build-consumer/
|
||||
.claude/settings.local.json
|
||||
.dart_tool/
|
||||
.gradle/
|
||||
|
||||
@@ -113,6 +113,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`.
|
||||
|
||||
+286
-13
@@ -1,10 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(reaktor C CXX)
|
||||
project(reaktor VERSION 0.2.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")
|
||||
|
||||
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,23 +199,26 @@ 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)
|
||||
if(REAKTOR_TESTS AND NOT EMSCRIPTEN)
|
||||
add_executable(animtest tools/animtest.c core/anim/anim.c)
|
||||
target_link_libraries(animtest PRIVATE reaktor_headers)
|
||||
target_include_directories(animtest PRIVATE core/anim core/a11y core/render
|
||||
platform)
|
||||
target_link_libraries(animtest PRIVATE SDL3::SDL3)
|
||||
@@ -208,12 +228,14 @@ if(NOT EMSCRIPTEN)
|
||||
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
|
||||
@@ -229,8 +251,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"
|
||||
@@ -375,8 +403,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)
|
||||
@@ -475,6 +504,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 +542,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 +665,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 +682,245 @@ 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(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()
|
||||
|
||||
@@ -6,11 +6,6 @@ A Nuklear-powered GUI library for C.
|
||||
<img src="assets/screenshots/screenshot.png" alt="Two Reaktor showcase windows, the light scheme behind and the dark scheme in front: each has the sidebar of pages with its own scheme chosen at the foot, and the front one shows the Login page's card in a rounded panel">
|
||||
</p>
|
||||
|
||||
**[Try the showcase in your browser](https://alpaq92.github.io/Reaktor/)** — the
|
||||
same program, built to WebAssembly — or
|
||||
**[download it](https://github.com/Alpaq92/Reaktor/releases/latest)** for
|
||||
Windows, macOS or Linux.
|
||||
|
||||
Tired of C having no cross-platform GUI — nothing like
|
||||
[Avalonia](https://github.com/avaloniaui/avalonia),
|
||||
[Shaft](https://github.com/ShaftUI/Shaft) or
|
||||
@@ -18,6 +13,12 @@ Tired of C having no cross-platform GUI — nothing like
|
||||
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.
|
||||
|
||||
**[Try the showcase in your browser](https://alpaq92.github.io/Reaktor/)** — the
|
||||
same program, built to WebAssembly — or
|
||||
**[download it](https://github.com/Alpaq92/Reaktor/releases/latest)** for
|
||||
Windows, macOS, Linux, FreeBSD, OpenBSD or NetBSD, or as WebAssembly to serve
|
||||
yourself.
|
||||
|
||||
> ⚠️ **Reaktor is in active development**, and breaking changes might occur.
|
||||
|
||||
<p align="center">
|
||||
@@ -65,6 +66,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
|
||||
|
||||
@@ -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 = [System.IO.Path]::GetFullPath((Join-Path (Get-Location) $Out)) }
|
||||
$srcDir = if ($Source) { [System.IO.Path]::GetFullPath((Join-Path (Get-Location) $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;
|
||||
|
||||
+1
-30
@@ -2,35 +2,7 @@
|
||||
#define REAKTOR_ANIM_H
|
||||
|
||||
#include "a11y.h"
|
||||
|
||||
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);
|
||||
#include "reaktor/anim.h"
|
||||
|
||||
void reaktor_anim_scope(const void *owner);
|
||||
|
||||
@@ -38,5 +10,4 @@ int reaktor_anim_tick(float dt_ms);
|
||||
|
||||
void reaktor_anim_evict(const reaktor_a11y_change *changes, int n);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+1
-32
@@ -1,41 +1,10 @@
|
||||
#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]);
|
||||
|
||||
#endif
|
||||
|
||||
+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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
+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
|
||||
|
||||
+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
|
||||
|
||||
+1
-27
@@ -3,33 +3,7 @@
|
||||
|
||||
#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
|
||||
|
||||
+9
-1
@@ -1157,6 +1157,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 +1221,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];
|
||||
}
|
||||
|
||||
+83
-20
@@ -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,9 @@ 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_dark(app)`, `reaktor_get_theme(app)` | Whether it draws dark; the scheme chosen |
|
||||
| `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,7 +113,7 @@ 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 |
|
||||
| --- | --- | --- | --- |
|
||||
@@ -222,7 +233,7 @@ logs the box.
|
||||
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
|
||||
|
||||
@@ -386,7 +397,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.
|
||||
|
||||
@@ -430,23 +441,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_font`, `reaktor_style_font` | A baked face, by size or by selector |
|
||||
| `reaktor_ionicon` | An Ionicon as an `nk_image` |
|
||||
| `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_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).
|
||||
|
||||
---
|
||||
|
||||
@@ -549,23 +564,69 @@ writes a `--shot` and an `--a11y-dump` of `simple` and the showcase through
|
||||
the system's video driver and SDL's `dummy` one: `.github/workflows/` holds a
|
||||
workflow per system. The BSDs run in virtual machines, ARM64 among them under
|
||||
emulation, and a job that emulates may fail without failing its run. The web
|
||||
build is checked by hand in headless Edge, as desktop, Android and iOS.
|
||||
build is built and packed on every pull request too (`web.yml`), and checked
|
||||
by hand in headless Edge, as desktop, Android and iOS.
|
||||
|
||||
`build.sh` builds for the machine it runs on. `build.ps1 -Arch x86` (or `x64`,
|
||||
`arm64`) builds that architecture with MSVC's matching toolset, into
|
||||
`build-<arch>` when it is not the machine's own; ARM64 needs Visual Studio's
|
||||
ARM64 build tools.
|
||||
|
||||
**Releases.** Pushing a `v*` tag runs `release.yml`: the three workflows
|
||||
again, with every job required, and a GitHub release of what they packed —
|
||||
one archive per system and architecture, and the source with its submodules,
|
||||
which GitHub's own archives leave out. `tools/package.sh <build> <folder>
|
||||
[.exe]` packs 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 checks it
|
||||
draws its Translations page as the built one does. Windows links the 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.
|
||||
**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, 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
|
||||
checks it draws its Translations page as the built one does. Windows links the
|
||||
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.
|
||||
|
||||
**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, 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 and SDL's, a CMake
|
||||
package, a pkg-config file and `share/reaktor/licenses`:
|
||||
|
||||
```cmake
|
||||
find_package(reaktor 0.2 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
|
||||
|
||||
@@ -583,6 +644,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.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(consumer C)
|
||||
|
||||
find_package(reaktor 0.2 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,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,33 @@
|
||||
#ifndef REAKTOR_ANIM_PUBLIC_H
|
||||
#define REAKTOR_ANIM_PUBLIC_H
|
||||
|
||||
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);
|
||||
|
||||
#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,14 @@ 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);
|
||||
int reaktor_dark(App *app);
|
||||
reaktor_theme reaktor_get_theme(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,32 @@
|
||||
#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);
|
||||
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);
|
||||
|
||||
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,37 @@
|
||||
#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;
|
||||
|
||||
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,135 @@
|
||||
#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);
|
||||
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);
|
||||
|
||||
#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);
|
||||
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,274 @@
|
||||
#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;
|
||||
} 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
|
||||
+58
-10
@@ -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;
|
||||
@@ -517,7 +517,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 +546,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 +645,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 +678,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;
|
||||
|
||||
@@ -1486,7 +1486,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;
|
||||
}
|
||||
@@ -1726,3 +1725,52 @@ 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;
|
||||
}
|
||||
|
||||
reaktor_theme
|
||||
reaktor_get_theme(App *app)
|
||||
{
|
||||
return app ? (reaktor_theme)app->theme_mode : REAKTOR_THEME_SYSTEM;
|
||||
}
|
||||
|
||||
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,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);
|
||||
|
||||
+134
-88
@@ -1,12 +1,48 @@
|
||||
#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 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 +64,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 +120,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 +128,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 +164,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 +188,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 +203,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 +223,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,7 +271,7 @@ 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 card_h = card_height(g_show_contact);
|
||||
float side = body_x + (body_w - (float)CARD_W) * 0.5f;
|
||||
float top = body_y + (body_h - card_height(0)) * 0.5f;
|
||||
|
||||
@@ -246,7 +286,8 @@ login_card(App *app, struct nk_context *ctx, float body_x, float body_w,
|
||||
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));
|
||||
@@ -292,13 +333,13 @@ 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;
|
||||
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",
|
||||
@@ -319,7 +360,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 +374,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 +387,9 @@ 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 = reaktor_token(on ? "--links" : "--text-muted", text_main());
|
||||
struct nk_rect b;
|
||||
style_frame look;
|
||||
shell_style look;
|
||||
unsigned id;
|
||||
int hit;
|
||||
|
||||
@@ -359,7 +400,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,19 +415,8 @@ 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
|
||||
|
||||
@@ -407,7 +437,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]));
|
||||
@@ -437,7 +467,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 +490,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 +549,57 @@ 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_token("--background-body", nk_rgb(247, 247, 247)));
|
||||
}
|
||||
|
||||
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,7 +607,7 @@ 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)) {
|
||||
@@ -588,10 +638,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 +651,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 +667,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,
|
||||
|
||||
+18
-22
@@ -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"
|
||||
};
|
||||
@@ -679,11 +673,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 +687,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 +716,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,
|
||||
@@ -2445,16 +2441,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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
+3
-6
@@ -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
|
||||
@@ -130,8 +130,6 @@ struct App {
|
||||
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,7 +149,7 @@ 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;
|
||||
@@ -172,7 +170,6 @@ struct App {
|
||||
unsigned char hot_last_repaint;
|
||||
|
||||
int dirty;
|
||||
int show_contact;
|
||||
|
||||
struct input_queue {
|
||||
SDL_Event *ev;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user