mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-01 07:24:56 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a36e5aa060 |
No files matched your search
@@ -0,0 +1,75 @@
|
||||
name: Build Linux Bundle
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
push_to_cache:
|
||||
description: "Push to Nix Cache"
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
|
||||
- name: Free disk space
|
||||
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
|
||||
|
||||
- name: Build Nix Package
|
||||
run: nix build .nix --no-link --print-out-paths
|
||||
|
||||
- name: Push to Nix Cache
|
||||
if: github.ref == 'refs/heads/master' || inputs.push_to_cache == true
|
||||
env:
|
||||
NIX_CACHE_AUTH_TOKEN: ${{ secrets.NIX_CACHE_AUTH_TOKEN }}
|
||||
run: |
|
||||
nix run nixpkgs#cachix -- authtoken $NIX_CACHE_AUTH_TOKEN
|
||||
nix build .nix --no-link --print-out-paths | nix run nixpkgs#cachix -- push graphite
|
||||
|
||||
- name: Build Linux Bundle
|
||||
run: nix build .nix#graphite-bundle.tar.xz && cp ./result ./graphite-linux-bundle.tar.xz
|
||||
|
||||
- name: Upload Linux Bundle
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: graphite-linux-bundle
|
||||
path: graphite-linux-bundle.tar.xz
|
||||
compression-level: 0
|
||||
|
||||
- name: Setup Flatpak Tooling
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y flatpak flatpak-builder
|
||||
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
- name: Build Flatpak
|
||||
run: |
|
||||
nix build .nix#graphite-flatpak-manifest
|
||||
|
||||
rm -rf .flatpak
|
||||
mkdir -p .flatpak
|
||||
|
||||
cp ./result .flatpak/manifest.json
|
||||
|
||||
cd .flatpak
|
||||
mkdir -p repo
|
||||
|
||||
flatpak-builder --user --force-clean --install-deps-from=flathub --repo=repo build ./manifest.json
|
||||
|
||||
flatpak build-bundle repo Graphite.flatpak art.graphite.Graphite --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
- name: Upload Flatpak
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: graphite-flatpak
|
||||
path: .flatpak/Graphite.flatpak
|
||||
compression-level: 0
|
||||
@@ -0,0 +1,157 @@
|
||||
name: Build Mac Bundle
|
||||
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
|
||||
env:
|
||||
WASM_BINDGEN_CLI_VERSION: "0.2.100"
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
rustflags: ""
|
||||
target: wasm32-unknown-unknown
|
||||
|
||||
- name: Cache Cargo
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
cache: npm
|
||||
cache-dependency-path: |
|
||||
package-lock.json
|
||||
frontend/package-lock.json
|
||||
|
||||
- name: Install Native Dependencies
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
BINSTALL_DISABLE_TELEMETRY: "true"
|
||||
run: |
|
||||
brew update
|
||||
brew install \
|
||||
pkg-config \
|
||||
openssl@3 \
|
||||
binaryen \
|
||||
llvm \
|
||||
cargo-binstall
|
||||
|
||||
echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
|
||||
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> $GITHUB_ENV
|
||||
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
|
||||
|
||||
cargo binstall --no-confirm --force wasm-pack
|
||||
cargo binstall --no-confirm --force cargo-about
|
||||
cargo binstall --no-confirm --force "wasm-bindgen-cli@${WASM_BINDGEN_CLI_VERSION}"
|
||||
|
||||
- name: Build Mac Bundle
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
run: npm run build-desktop
|
||||
|
||||
- name: Stage Artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
rm -rf target/artifacts
|
||||
mkdir -p target/artifacts
|
||||
cp -R target/release/Graphite.app target/artifacts/Graphite.app
|
||||
|
||||
- name: Upload Mac Bundle
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: graphite-mac-bundle
|
||||
path: target/artifacts
|
||||
|
||||
- name: Sign and Notarize Mac Bundle Preparation
|
||||
if: github.ref == 'refs/heads/master'
|
||||
env:
|
||||
APPLE_CERT_BASE64: ${{ secrets.APPLE_CERT_BASE64 }}
|
||||
APPLE_CERT_PASSWORD: ${{ secrets.APPLE_CERT_PASSWORD }}
|
||||
run: |
|
||||
mkdir -p .sign
|
||||
echo "$APPLE_CERT_BASE64" | base64 --decode > .sign/certificate.p12
|
||||
|
||||
security create-keychain -p "" .sign/main.keychain
|
||||
security default-keychain -s .sign/main.keychain
|
||||
security unlock-keychain -p "" .sign/main.keychain
|
||||
security set-keychain-settings -t 3600 -u .sign/main.keychain
|
||||
|
||||
security import .sign/certificate.p12 -k .sign/main.keychain -P "$APPLE_CERT_PASSWORD" -T /usr/bin/codesign -T /usr/bin/productsign
|
||||
security set-key-partition-list -S apple-tool:,apple: -s -k "" .sign/main.keychain
|
||||
|
||||
cat > .sign/entitlements.plist <<'EOF'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-executable-page-protection</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
- name: Sign and Notarize Mac Bundle
|
||||
if: github.ref == 'refs/heads/master'
|
||||
env:
|
||||
APPLE_EMAIL: ${{ secrets.APPLE_EMAIL }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||
APPLE_CERT_NAME: ${{ secrets.APPLE_CERT_NAME }}
|
||||
run: |
|
||||
CERTIFICATE="$APPLE_CERT_NAME"
|
||||
ENTITLEMENTS=".sign/entitlements.plist"
|
||||
APP_PATH="target/artifacts/Graphite.app"
|
||||
ZIP_PATH=".sign/Graphite.zip"
|
||||
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Graphite Helper.app"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Graphite Helper (GPU).app"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Graphite Helper (Renderer).app"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/libcef_sandbox.dylib"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/libEGL.dylib"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/libGLESv2.dylib"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/libvk_swiftshader.dylib"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH" --deep
|
||||
|
||||
codesign --verify --deep --strict --verbose=4 "$APP_PATH"
|
||||
|
||||
ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
|
||||
xcrun notarytool submit "$ZIP_PATH" --wait --apple-id "$APPLE_EMAIL" --team-id "$APPLE_TEAM_ID" --password "$APPLE_PASSWORD"
|
||||
rm "$ZIP_PATH"
|
||||
|
||||
xcrun stapler staple -v "$APP_PATH"
|
||||
|
||||
spctl -a -vv "$APP_PATH"
|
||||
|
||||
- name: Upload Mac Bundle Signed
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: graphite-mac-bundle-signed
|
||||
path: target/artifacts
|
||||
@@ -0,0 +1,17 @@
|
||||
name: Build Nix Package
|
||||
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
- name: Build Nix Package Dev
|
||||
run: nix build .nix#graphite-dev --print-build-logs
|
||||
@@ -0,0 +1,79 @@
|
||||
name: "Editor: Production (Latest Stable)"
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "latest-stable"
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: self-hosted
|
||||
permissions:
|
||||
contents: write
|
||||
deployments: write
|
||||
env:
|
||||
RUSTC_WRAPPER: /usr/bin/sccache
|
||||
CARGO_INCREMENTAL: 0
|
||||
SCCACHE_DIR: /var/lib/github-actions/.cache
|
||||
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="editor.graphite.art" data-api="https://graphite.art/visit/event" src="https://graphite.art/visit/script.hash.js"></script>
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🗑 Clear wasm-bindgen cache
|
||||
run: rm -r ~/.cache/.wasm-pack
|
||||
|
||||
- name: 🟢 Install the latest Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "latest"
|
||||
|
||||
- name: 🚧 Install build dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm run setup
|
||||
|
||||
- name: 🦀 Install the latest Rust
|
||||
run: |
|
||||
echo "Initial system version:"
|
||||
rustc --version
|
||||
rustup update stable
|
||||
echo "Latest updated version:"
|
||||
rustc --version
|
||||
|
||||
- name: ✂ Replace template in <head> of index.html
|
||||
run: |
|
||||
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
|
||||
|
||||
- name: 🌐 Build Graphite web code
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
mold -run npm run build
|
||||
|
||||
- name: 📤 Publish to Cloudflare Pages
|
||||
id: cloudflare
|
||||
uses: cloudflare/pages-action@1
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
projectName: graphite-editor
|
||||
directory: frontend/dist
|
||||
branch: master
|
||||
|
||||
- name: 📦 Upload assets to GitHub release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
DATE=$(git log -1 --format=%cd --date=format:%Y-%m-%d)
|
||||
cd frontend
|
||||
sed -i "s|$INDEX_HTML_HEAD_REPLACEMENT||" dist/index.html
|
||||
mv dist "graphite-$DATE"
|
||||
zip -r "graphite-self-hosted-build.zip" "graphite-$DATE"
|
||||
gh release upload latest-stable "graphite-self-hosted-build.zip" --clobber
|
||||
@@ -0,0 +1,173 @@
|
||||
name: Build Windows Bundle
|
||||
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
|
||||
env:
|
||||
WASM_BINDGEN_CLI_VERSION: "0.2.100"
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
rustflags: ""
|
||||
target: wasm32-unknown-unknown
|
||||
|
||||
- name: Cache Cargo
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
${{ env.USERPROFILE }}\.cargo\registry
|
||||
${{ env.USERPROFILE }}\.cargo\git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
cache: npm
|
||||
cache-dependency-path: |
|
||||
package-lock.json
|
||||
frontend/package-lock.json
|
||||
|
||||
- name: Setup Cargo Binstall
|
||||
uses: cargo-bins/cargo-binstall@main
|
||||
|
||||
- name: Install Native Dependencies
|
||||
shell: pwsh
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
BINSTALL_DISABLE_TELEMETRY: "true"
|
||||
run: |
|
||||
winget install --id LLVM.LLVM -e --accept-package-agreements --accept-source-agreements
|
||||
winget install --id Kitware.CMake -e --accept-package-agreements --accept-source-agreements
|
||||
winget install --id OpenSSL.OpenSSL -e --accept-package-agreements --accept-source-agreements
|
||||
winget install --id WebAssembly.Binaryen -e --accept-package-agreements --accept-source-agreements
|
||||
winget install --id GnuWin32.PkgConfig -e --accept-package-agreements --accept-source-agreements
|
||||
|
||||
"OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"PKG_CONFIG_PATH=C:\Program Files\OpenSSL-Win64\lib\pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
|
||||
cargo binstall --no-confirm --force wasm-pack
|
||||
cargo binstall --no-confirm --force cargo-about
|
||||
cargo binstall --no-confirm --force "wasm-bindgen-cli@$env:WASM_BINDGEN_CLI_VERSION"
|
||||
|
||||
- name: Build Windows Bundle
|
||||
shell: bash # `cargo-about` refuses to run in powershell
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
run: npm run build-desktop
|
||||
|
||||
- name: Stage Artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
rm -rf target/artifacts
|
||||
mkdir -p target/artifacts
|
||||
cp -R target/release/Graphite target/artifacts/Graphite
|
||||
|
||||
- name: Upload Windows Bundle
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: graphite-windows-bundle
|
||||
path: target/artifacts
|
||||
|
||||
- name: Azure login
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: azure/login@v1
|
||||
with:
|
||||
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
||||
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
||||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
||||
enable-AzPSSession: true
|
||||
|
||||
- name: Sign
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: azure/artifact-signing-action@v1
|
||||
with:
|
||||
endpoint: https://eus.codesigning.azure.net/
|
||||
signing-account-name: Graphite
|
||||
certificate-profile-name: Graphite
|
||||
files: |
|
||||
${{ github.workspace }}\target\artifacts\Graphite\Graphite.exe
|
||||
${{ github.workspace }}\target\artifacts\Graphite\libcef.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\chrome_elf.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\vulkan-1.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\dxcompiler.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\libEGL.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\libGLESv2.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\vk_swiftshader.dll
|
||||
file-digest: SHA256
|
||||
timestamp-rfc3161: http://timestamp.acs.microsoft.com
|
||||
timestamp-digest: SHA256
|
||||
correlation-id: ${{ github.sha }}
|
||||
|
||||
- name: Verify Signatures
|
||||
if: github.ref == 'refs/heads/master'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$TargetDir = "target\artifacts\Graphite"
|
||||
|
||||
if (-not (Test-Path $TargetDir)) {
|
||||
throw "TargetDir not found: $TargetDir"
|
||||
}
|
||||
|
||||
$UnsignedOrBad = @()
|
||||
|
||||
Get-ChildItem -Path $TargetDir -Recurse -File -Include *.exe,*.dll | ForEach-Object {
|
||||
$sig = Get-AuthenticodeSignature -FilePath $_.FullName
|
||||
|
||||
if ($sig.Status -ne 'Valid') {
|
||||
$UnsignedOrBad += "$($_.FullName) (Status=$($sig.Status))"
|
||||
}
|
||||
}
|
||||
|
||||
if ($UnsignedOrBad.Count -gt 0) {
|
||||
Write-Host "Unsigned or invalid binaries detected:"
|
||||
$UnsignedOrBad | ForEach-Object {
|
||||
Write-Host "::error::$_"
|
||||
}
|
||||
|
||||
if ($env:GITHUB_STEP_SUMMARY) {
|
||||
"### ❌ Unsigned or invalid binaries detected" |
|
||||
Out-File $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
|
||||
"" | Out-File $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
|
||||
$UnsignedOrBad | ForEach-Object {
|
||||
"* `$_" | Out-File $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
|
||||
}
|
||||
}
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "All binaries are signed and valid."
|
||||
|
||||
if ($env:GITHUB_STEP_SUMMARY) {
|
||||
"### ✅ All binaries are signed and valid" |
|
||||
Out-File $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
|
||||
}
|
||||
|
||||
- name: Upload Windows Bundle Signed
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: graphite-windows-bundle-signed
|
||||
path: target/artifacts
|
||||
@@ -1,730 +0,0 @@
|
||||
name: "Build"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- latest-stable
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
web:
|
||||
description: "Web"
|
||||
type: boolean
|
||||
windows:
|
||||
description: "Windows"
|
||||
type: boolean
|
||||
mac:
|
||||
description: "Mac"
|
||||
type: boolean
|
||||
linux:
|
||||
description: "Linux"
|
||||
type: boolean
|
||||
push_to_nix_cache:
|
||||
description: "Linux: push to Nix cache"
|
||||
type: boolean
|
||||
debug:
|
||||
description: "Debug build"
|
||||
type: boolean
|
||||
workflow_call:
|
||||
inputs:
|
||||
web:
|
||||
type: boolean
|
||||
windows:
|
||||
type: boolean
|
||||
mac:
|
||||
type: boolean
|
||||
linux:
|
||||
type: boolean
|
||||
push_to_nix_cache:
|
||||
type: boolean
|
||||
debug:
|
||||
type: boolean
|
||||
checkout_repo:
|
||||
type: string
|
||||
checkout_ref:
|
||||
type: string
|
||||
pr_number:
|
||||
type: string
|
||||
merge_queue:
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
web:
|
||||
if: github.event_name == 'push' || inputs.web
|
||||
runs-on: [self-hosted, target/wasm]
|
||||
permissions:
|
||||
contents: write
|
||||
deployments: write
|
||||
pull-requests: write
|
||||
actions: write
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUSTC_WRAPPER: /usr/bin/sccache
|
||||
CARGO_INCREMENTAL: 0
|
||||
SCCACHE_DIR: /var/lib/github-actions/.cache
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: ${{ inputs.checkout_repo || github.repository }}
|
||||
ref: ${{ inputs.checkout_ref || '' }}
|
||||
|
||||
- name: 🗑 Clear wasm-bindgen cache
|
||||
run: rm -r ~/.cache/.wasm-pack || true
|
||||
|
||||
- name: 🟢 Install Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
|
||||
- name: 🚧 Install build dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm run setup
|
||||
|
||||
- name: 🦀 Install Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
cache: false
|
||||
rustflags: ""
|
||||
target: wasm32-unknown-unknown
|
||||
|
||||
- name: 🔀 Choose production deployment environment and insert template
|
||||
id: production-env
|
||||
if: github.event_name == 'push'
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == "refs/tags/latest-stable" ]]; then
|
||||
echo "cf_project=graphite-editor" >> $GITHUB_OUTPUT
|
||||
DOMAIN="editor.graphite.art"
|
||||
else
|
||||
echo "cf_project=graphite-dev" >> $GITHUB_OUTPUT
|
||||
DOMAIN="dev.graphite.art"
|
||||
fi
|
||||
TEMPLATE="<script defer data-domain=\"$DOMAIN\" data-api=\"https://graphite.art/visit/event\" src=\"https://graphite.art/visit/script.hash.js\"></script>"
|
||||
echo "template=$TEMPLATE" >> $GITHUB_OUTPUT
|
||||
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$TEMPLATE|" frontend/index.html
|
||||
|
||||
- name: 🌐 Build Graphite web code
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: mold -run cargo run build web${{ inputs.debug && ' debug' || '' }}
|
||||
|
||||
- name: 📤 Publish to Cloudflare Pages
|
||||
if: inputs.merge_queue == false
|
||||
id: cloudflare
|
||||
continue-on-error: ${{ github.event_name != 'push' }}
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
run: |
|
||||
if [ -z "$CLOUDFLARE_API_TOKEN" ]; then
|
||||
echo "No Cloudflare API token available (fork PR), skipping deploy."
|
||||
exit 0
|
||||
fi
|
||||
MAX_ATTEMPTS=8
|
||||
DELAY=15
|
||||
for ATTEMPT in $(seq 1 $MAX_ATTEMPTS); do
|
||||
echo "Attempt $ATTEMPT of $MAX_ATTEMPTS..."
|
||||
npx wrangler@3 pages deploy "frontend/dist" --project-name="${{ steps.production-env.outputs.cf_project || 'graphite-dev' }}" --commit-dirty=true 2>&1 | tee /tmp/wrangler_output
|
||||
if [ ${PIPESTATUS[0]} -eq 0 ]; then
|
||||
URL=$(grep -oP 'https://[^\s]+\.pages\.dev' /tmp/wrangler_output | head -1)
|
||||
echo "url=$URL" >> "$GITHUB_OUTPUT"
|
||||
echo "Published successfully: $URL"
|
||||
exit 0
|
||||
fi
|
||||
echo "Attempt $ATTEMPT failed."
|
||||
if [ "$ATTEMPT" -lt "$MAX_ATTEMPTS" ]; then
|
||||
echo "Retrying in ${DELAY}s..."
|
||||
sleep $DELAY
|
||||
DELAY=$((DELAY * 2))
|
||||
fi
|
||||
done
|
||||
echo "All $MAX_ATTEMPTS Cloudflare Pages publish attempts failed."
|
||||
exit 1
|
||||
|
||||
- name: 🚀 Create a GitHub environment deployment
|
||||
if: (inputs.checkout_repo == '' || inputs.checkout_repo == github.repository) && inputs.merge_queue == false
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CF_URL: ${{ steps.cloudflare.outputs.url }}
|
||||
run: |
|
||||
if [ -z "$CF_URL" ]; then
|
||||
echo "No Cloudflare URL available, skipping deployment."
|
||||
exit 0
|
||||
fi
|
||||
if [ "${{ github.ref }}" = "refs/tags/latest-stable" ]; then
|
||||
REF="latest-stable"
|
||||
ENVIRONMENT="graphite-editor (Production)"
|
||||
elif [ "${{ github.event_name }}" = "push" ]; then
|
||||
REF="master"
|
||||
ENVIRONMENT="graphite-dev (Production)"
|
||||
else
|
||||
REF="${{ inputs.checkout_ref || github.head_ref || github.ref_name }}"
|
||||
ENVIRONMENT="graphite-dev (Preview)"
|
||||
fi
|
||||
DEPLOY_ID=$(gh api \
|
||||
-X POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
repos/${{ github.repository }}/deployments \
|
||||
--input - \
|
||||
--jq '.id' <<EOF
|
||||
{"ref":"$REF","environment":"$ENVIRONMENT","auto_merge":false,"required_contexts":[]}
|
||||
EOF
|
||||
)
|
||||
gh api \
|
||||
-X POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
repos/${{ github.repository }}/deployments/$DEPLOY_ID/statuses \
|
||||
-f state=success \
|
||||
-f environment_url="$CF_URL" \
|
||||
-f log_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
||||
|
||||
- name: 💬 Comment with the build link
|
||||
if: github.event_name != 'pull_request' && inputs.merge_queue == false
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CF_URL: ${{ steps.cloudflare.outputs.url }}
|
||||
run: |
|
||||
if [ -z "$CF_URL" ]; then
|
||||
echo "No Cloudflare URL available, skipping comment."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
COMMENT_BODY="| 📦 **Web Build Complete for** $(git rev-parse HEAD) |
|
||||
|-|
|
||||
| $CF_URL |"
|
||||
|
||||
if [ "${{ github.ref }}" = "refs/tags/latest-stable" ]; then
|
||||
# Push tag: skip commenting (commit was already commented on master merge)
|
||||
echo "Tag push, skipping comment."
|
||||
elif [ "${{ github.event_name }}" = "push" ]; then
|
||||
# Push master: comment on the commit hash page
|
||||
gh api \
|
||||
-X POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
repos/${{ github.repository }}/commits/$(git rev-parse HEAD)/comments \
|
||||
-f body="$COMMENT_BODY"
|
||||
elif [ "${{ github.event_name }}" != "pull_request" ]; then
|
||||
# Manual trigger (workflow_dispatch, !build): comment on the PR
|
||||
PR_NUMBER="${{ inputs.pr_number }}"
|
||||
if [ -z "$PR_NUMBER" ]; then
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null || true)
|
||||
fi
|
||||
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
gh pr comment "$PR_NUMBER" --repo ${{ github.repository }} --body "$COMMENT_BODY"
|
||||
else
|
||||
echo "No open PR found, skipping comment."
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: ✂ Strip template from completed build for a clean artifact
|
||||
if: github.event_name == 'push'
|
||||
env:
|
||||
TEMPLATE: ${{ steps.production-env.outputs.template }}
|
||||
run: sed -i "s|$TEMPLATE||" frontend/dist/index.html
|
||||
|
||||
- name: 📦 Upload web bundle artifact
|
||||
if: github.event_name != 'pull_request' && inputs.merge_queue == false
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: graphite-web-bundle
|
||||
path: frontend/dist
|
||||
|
||||
- name: 👕 Lint Graphite web formatting
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
npm run check
|
||||
|
||||
- name: 📃 Trigger website rebuild if auto-generated code docs are stale
|
||||
if: github.event_name == 'push' && github.ref != 'refs/tags/latest-stable'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
cargo run -p editor-message-tree -- website/generated
|
||||
TREE=volunteer/guide/codebase-overview/hierarchical-message-system-tree
|
||||
curl -sf "https://graphite.art/$TREE.txt" -o "website/static/$TREE.live.txt" \
|
||||
&& diff -q "website/static/$TREE.txt" "website/static/$TREE.live.txt" > /dev/null \
|
||||
|| gh workflow run website.yml --ref master
|
||||
|
||||
windows:
|
||||
if: (github.event_name == 'push' && github.ref != 'refs/tags/latest-stable') || inputs.windows
|
||||
runs-on: windows-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
WASM_BINDGEN_CLI_VERSION: "0.2.100"
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: ${{ inputs.checkout_repo || github.repository }}
|
||||
ref: ${{ inputs.checkout_ref || '' }}
|
||||
|
||||
- name: 🦀 Install Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
cache: false
|
||||
rustflags: ""
|
||||
target: wasm32-unknown-unknown
|
||||
|
||||
- name: 💾 Set up Cargo cache
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: 🟢 Install Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
cache: npm
|
||||
cache-dependency-path: |
|
||||
package-lock.json
|
||||
frontend/package-lock.json
|
||||
|
||||
- name: 📦 Install Cargo-binstall
|
||||
uses: cargo-bins/cargo-binstall@main
|
||||
|
||||
- name: 🚧 Install native dependencies
|
||||
shell: pwsh
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
BINSTALL_DISABLE_TELEMETRY: "true"
|
||||
run: |
|
||||
winget install --id LLVM.LLVM -e --accept-package-agreements --accept-source-agreements
|
||||
winget install --id Kitware.CMake -e --accept-package-agreements --accept-source-agreements
|
||||
winget install --id OpenSSL.OpenSSL -e --accept-package-agreements --accept-source-agreements
|
||||
winget install --id WebAssembly.Binaryen -e --accept-package-agreements --accept-source-agreements
|
||||
winget install --id GnuWin32.PkgConfig -e --accept-package-agreements --accept-source-agreements
|
||||
|
||||
"OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
"PKG_CONFIG_PATH=C:\Program Files\OpenSSL-Win64\lib\pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
|
||||
cargo binstall --no-confirm --force wasm-pack
|
||||
cargo binstall --no-confirm --force cargo-about
|
||||
cargo binstall --no-confirm --force "wasm-bindgen-cli@$env:WASM_BINDGEN_CLI_VERSION"
|
||||
|
||||
- name: 🏗 Build Windows bundle
|
||||
shell: bash # `cargo-about` refuses to run in powershell
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
run: cargo run build desktop${{ inputs.debug && ' debug' || '' }}
|
||||
|
||||
- name: 📁 Stage artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
PROFILE=${{ inputs.debug && 'debug' || 'release' }}
|
||||
rm -rf target/artifacts
|
||||
mkdir -p target/artifacts
|
||||
cp -R target/$PROFILE/Graphite target/artifacts/Graphite
|
||||
|
||||
- name: 📦 Upload Windows bundle
|
||||
if: github.event_name != 'push'
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: graphite-windows-bundle
|
||||
path: target/artifacts
|
||||
|
||||
- name: 💬 Comment artifact link on PR
|
||||
if: github.event_name != 'push'
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
ARTIFACT_ID=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --jq '.artifacts[] | select(.name == "graphite-windows-bundle") | .id')
|
||||
ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/$ARTIFACT_ID"
|
||||
PR_NUMBER="${{ inputs.pr_number }}"
|
||||
if [ -z "$PR_NUMBER" ]; then
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null || true)
|
||||
fi
|
||||
if [ -n "$PR_NUMBER" ] && [ -n "$ARTIFACT_ID" ]; then
|
||||
BODY="| 📦 **Windows Build Complete for** $(git rev-parse HEAD) |"$'\n'
|
||||
BODY+="|-|"$'\n'
|
||||
BODY+="| [Download binary]($ARTIFACT_URL) |"
|
||||
gh pr comment "$PR_NUMBER" --repo ${{ github.repository }} --body "$BODY"
|
||||
fi
|
||||
|
||||
- name: 🔑 Azure login
|
||||
if: github.event_name == 'push'
|
||||
uses: azure/login@v1
|
||||
with:
|
||||
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
||||
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
||||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
||||
enable-AzPSSession: true
|
||||
|
||||
- name: 🔏 Sign
|
||||
if: github.event_name == 'push'
|
||||
uses: azure/artifact-signing-action@v1
|
||||
with:
|
||||
endpoint: https://eus.codesigning.azure.net/
|
||||
signing-account-name: Graphite
|
||||
certificate-profile-name: Graphite
|
||||
files: |
|
||||
${{ github.workspace }}\target\artifacts\Graphite\Graphite.exe
|
||||
${{ github.workspace }}\target\artifacts\Graphite\libcef.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\chrome_elf.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\vulkan-1.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\dxcompiler.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\libEGL.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\libGLESv2.dll
|
||||
${{ github.workspace }}\target\artifacts\Graphite\vk_swiftshader.dll
|
||||
file-digest: SHA256
|
||||
timestamp-rfc3161: http://timestamp.acs.microsoft.com
|
||||
timestamp-digest: SHA256
|
||||
correlation-id: ${{ github.sha }}
|
||||
|
||||
- name: ✅ Verify signatures
|
||||
if: github.event_name == 'push'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$TargetDir = "target\artifacts\Graphite"
|
||||
|
||||
if (-not (Test-Path $TargetDir)) {
|
||||
throw "TargetDir not found: $TargetDir"
|
||||
}
|
||||
|
||||
$UnsignedOrBad = @()
|
||||
|
||||
Get-ChildItem -Path $TargetDir -Recurse -File -Include *.exe,*.dll | ForEach-Object {
|
||||
$sig = Get-AuthenticodeSignature -FilePath $_.FullName
|
||||
|
||||
if ($sig.Status -ne 'Valid') {
|
||||
$UnsignedOrBad += "$($_.FullName) (Status=$($sig.Status))"
|
||||
}
|
||||
}
|
||||
|
||||
if ($UnsignedOrBad.Count -gt 0) {
|
||||
Write-Host "Unsigned or invalid binaries detected:"
|
||||
$UnsignedOrBad | ForEach-Object {
|
||||
Write-Host "::error::$_"
|
||||
}
|
||||
|
||||
if ($env:GITHUB_STEP_SUMMARY) {
|
||||
"### ❌ Unsigned or invalid binaries detected" |
|
||||
Out-File $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
|
||||
"" | Out-File $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
|
||||
$UnsignedOrBad | ForEach-Object {
|
||||
"* `$_" | Out-File $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
|
||||
}
|
||||
}
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "All binaries are signed and valid."
|
||||
|
||||
if ($env:GITHUB_STEP_SUMMARY) {
|
||||
"### ✅ All binaries are signed and valid" |
|
||||
Out-File $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
|
||||
}
|
||||
|
||||
- name: 📦 Upload signed Windows bundle
|
||||
if: github.event_name == 'push'
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: graphite-windows-bundle-signed
|
||||
path: target/artifacts
|
||||
|
||||
mac:
|
||||
if: (github.event_name == 'push' && github.ref != 'refs/tags/latest-stable') || inputs.mac
|
||||
runs-on: macos-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
WASM_BINDGEN_CLI_VERSION: "0.2.100"
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: ${{ inputs.checkout_repo || github.repository }}
|
||||
ref: ${{ inputs.checkout_ref || '' }}
|
||||
|
||||
- name: 🦀 Install Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
cache: false
|
||||
rustflags: ""
|
||||
target: wasm32-unknown-unknown
|
||||
|
||||
- name: 💾 Set up Cargo cache
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: 🟢 Install Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
cache: npm
|
||||
cache-dependency-path: |
|
||||
package-lock.json
|
||||
frontend/package-lock.json
|
||||
|
||||
- name: 🚧 Install native dependencies
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
BINSTALL_DISABLE_TELEMETRY: "true"
|
||||
run: |
|
||||
brew update
|
||||
brew install \
|
||||
pkg-config \
|
||||
openssl@3 \
|
||||
binaryen \
|
||||
llvm \
|
||||
cargo-binstall
|
||||
|
||||
echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
|
||||
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> $GITHUB_ENV
|
||||
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
|
||||
|
||||
cargo binstall --no-confirm --force wasm-pack
|
||||
cargo binstall --no-confirm --force cargo-about
|
||||
cargo binstall --no-confirm --force "wasm-bindgen-cli@${WASM_BINDGEN_CLI_VERSION}"
|
||||
|
||||
- name: 🏗 Build Mac bundle
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
run: cargo run build desktop${{ inputs.debug && ' debug' || '' }}
|
||||
|
||||
- name: 📁 Stage artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
PROFILE=${{ inputs.debug && 'debug' || 'release' }}
|
||||
rm -rf target/artifacts
|
||||
mkdir -p target/artifacts
|
||||
cp -R target/$PROFILE/Graphite.app target/artifacts/Graphite.app
|
||||
|
||||
- name: 📦 Upload Mac bundle
|
||||
if: github.event_name != 'push'
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: graphite-mac-bundle
|
||||
path: target/artifacts
|
||||
|
||||
- name: 💬 Comment artifact link on PR
|
||||
if: github.event_name != 'push'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
ARTIFACT_ID=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --jq '.artifacts[] | select(.name == "graphite-mac-bundle") | .id')
|
||||
ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/$ARTIFACT_ID"
|
||||
PR_NUMBER="${{ inputs.pr_number }}"
|
||||
if [ -z "$PR_NUMBER" ]; then
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null || true)
|
||||
fi
|
||||
if [ -n "$PR_NUMBER" ] && [ -n "$ARTIFACT_ID" ]; then
|
||||
BODY="| 📦 **Mac Build Complete for** $(git rev-parse HEAD) |"$'\n'
|
||||
BODY+="|-|"$'\n'
|
||||
BODY+="| [Download binary]($ARTIFACT_URL) |"
|
||||
gh pr comment "$PR_NUMBER" --repo ${{ github.repository }} --body "$BODY"
|
||||
fi
|
||||
|
||||
- name: 🔏 Sign and notarize (preparation)
|
||||
if: github.event_name == 'push'
|
||||
env:
|
||||
APPLE_CERT_BASE64: ${{ secrets.APPLE_CERT_BASE64 }}
|
||||
APPLE_CERT_PASSWORD: ${{ secrets.APPLE_CERT_PASSWORD }}
|
||||
run: |
|
||||
mkdir -p .sign
|
||||
echo "$APPLE_CERT_BASE64" | base64 --decode > .sign/certificate.p12
|
||||
|
||||
security create-keychain -p "" .sign/main.keychain
|
||||
security default-keychain -s .sign/main.keychain
|
||||
security unlock-keychain -p "" .sign/main.keychain
|
||||
security set-keychain-settings -t 3600 -u .sign/main.keychain
|
||||
|
||||
security import .sign/certificate.p12 -k .sign/main.keychain -P "$APPLE_CERT_PASSWORD" -T /usr/bin/codesign -T /usr/bin/productsign
|
||||
security set-key-partition-list -S apple-tool:,apple: -s -k "" .sign/main.keychain
|
||||
|
||||
cat > .sign/entitlements.plist <<'EOF'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-executable-page-protection</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
- name: 🔏 Sign and notarize
|
||||
if: github.event_name == 'push'
|
||||
env:
|
||||
APPLE_EMAIL: ${{ secrets.APPLE_EMAIL }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||
APPLE_CERT_NAME: ${{ secrets.APPLE_CERT_NAME }}
|
||||
run: |
|
||||
CERTIFICATE="$APPLE_CERT_NAME"
|
||||
ENTITLEMENTS=".sign/entitlements.plist"
|
||||
APP_PATH="target/artifacts/Graphite.app"
|
||||
ZIP_PATH=".sign/Graphite.zip"
|
||||
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Graphite Helper.app"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Graphite Helper (GPU).app"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Graphite Helper (Renderer).app"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/libcef_sandbox.dylib"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/libEGL.dylib"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/libGLESv2.dylib"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/libvk_swiftshader.dylib"
|
||||
codesign --force --options runtime --entitlements "$ENTITLEMENTS" --sign "$CERTIFICATE" "$APP_PATH" --deep
|
||||
|
||||
codesign --verify --deep --strict --verbose=4 "$APP_PATH"
|
||||
|
||||
ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
|
||||
xcrun notarytool submit "$ZIP_PATH" --wait --apple-id "$APPLE_EMAIL" --team-id "$APPLE_TEAM_ID" --password "$APPLE_PASSWORD"
|
||||
rm "$ZIP_PATH"
|
||||
|
||||
xcrun stapler staple -v "$APP_PATH"
|
||||
|
||||
spctl -a -vv "$APP_PATH"
|
||||
|
||||
- name: 📦 Upload signed Mac bundle
|
||||
if: github.event_name == 'push'
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: graphite-mac-bundle-signed
|
||||
path: target/artifacts
|
||||
|
||||
linux:
|
||||
if: (github.event_name == 'push' && github.ref != 'refs/tags/latest-stable') || inputs.linux
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: ${{ inputs.checkout_repo || github.repository }}
|
||||
ref: ${{ inputs.checkout_ref || '' }}
|
||||
|
||||
- name: ❄ Install Nix
|
||||
uses: DeterminateSystems/nix-installer-action@main
|
||||
|
||||
- name: 🗑 Free disk space
|
||||
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
|
||||
|
||||
- name: 📦 Build Nix package
|
||||
run: nix build .#graphite${{ inputs.debug && '-dev' || '' }} --no-link --print-out-paths
|
||||
|
||||
- name: 📤 Push to Nix cache
|
||||
if: (github.event_name == 'push' || inputs.push_to_nix_cache) && !inputs.debug
|
||||
env:
|
||||
NIX_CACHE_AUTH_TOKEN: ${{ secrets.NIX_CACHE_AUTH_TOKEN }}
|
||||
run: |
|
||||
nix run nixpkgs#cachix -- authtoken $NIX_CACHE_AUTH_TOKEN
|
||||
nix build --no-link --print-out-paths | nix run nixpkgs#cachix -- push graphite
|
||||
|
||||
- name: 🏗 Build Linux bundle
|
||||
run: nix build .#graphite${{ inputs.debug && '-dev' || '' }}-bundle.tar.xz && cp ./result ./graphite-linux-bundle.tar.xz
|
||||
|
||||
- name: 📦 Upload Linux bundle
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: graphite-linux-bundle
|
||||
path: graphite-linux-bundle.tar.xz
|
||||
compression-level: 0
|
||||
|
||||
- name: 💬 Comment artifact link on PR
|
||||
id: linux-comment
|
||||
if: github.event_name != 'push'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
ARTIFACT_ID=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --jq '.artifacts[] | select(.name == "graphite-linux-bundle") | .id')
|
||||
ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/$ARTIFACT_ID"
|
||||
PR_NUMBER="${{ inputs.pr_number }}"
|
||||
if [ -z "$PR_NUMBER" ]; then
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null || true)
|
||||
fi
|
||||
if [ -n "$PR_NUMBER" ] && [ -n "$ARTIFACT_ID" ]; then
|
||||
BODY="| 📦 **Linux Build Complete for** $(git rev-parse HEAD) |"$'\n'
|
||||
BODY+="|-|"$'\n'
|
||||
BODY+="| [Download binary]($ARTIFACT_URL) |"
|
||||
COMMENT_ID=$(gh api repos/${{ github.repository }}/issues/$PR_NUMBER/comments -f body="$BODY" --jq '.id')
|
||||
echo "comment_id=$COMMENT_ID" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: 🔧 Install Flatpak tooling
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y flatpak flatpak-builder
|
||||
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
- name: 🏗 Build Flatpak
|
||||
run: |
|
||||
nix build .#graphite${{ inputs.debug && '-dev' || '' }}-flatpak-manifest
|
||||
|
||||
rm -rf .flatpak
|
||||
mkdir -p .flatpak
|
||||
|
||||
cp ./result .flatpak/manifest.json
|
||||
|
||||
cd .flatpak
|
||||
mkdir -p repo
|
||||
|
||||
flatpak-builder --user --force-clean --install-deps-from=flathub --repo=repo build ./manifest.json
|
||||
|
||||
flatpak build-bundle repo Graphite.flatpak art.graphite.Graphite --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
- name: 📦 Upload Flatpak package
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: graphite-flatpak
|
||||
path: .flatpak/Graphite.flatpak
|
||||
compression-level: 0
|
||||
|
||||
- name: 💬 Update PR comment with Flatpak artifact link
|
||||
if: github.event_name != 'push' && steps.linux-comment.outputs.comment_id
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
ARTIFACT_ID=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --jq '.artifacts[] | select(.name == "graphite-flatpak") | .id')
|
||||
ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/$ARTIFACT_ID"
|
||||
COMMENT_ID="${{ steps.linux-comment.outputs.comment_id }}"
|
||||
if [ -n "$ARTIFACT_ID" ]; then
|
||||
EXISTING_BODY=$(gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID --jq '.body')
|
||||
BODY="$EXISTING_BODY"$'\n'
|
||||
BODY+="| [Download Flatpak]($ARTIFACT_URL) |"
|
||||
gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID -X PATCH -f body="$BODY"
|
||||
fi
|
||||
@@ -1,9 +1,9 @@
|
||||
name: "Audit Security Advisories"
|
||||
|
||||
on:
|
||||
# Run once each week
|
||||
# Run once each day
|
||||
schedule:
|
||||
- cron: "0 0 * * 0"
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
cargo-deny:
|
||||
@@ -11,8 +11,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🔒 Check crate security advisories for root workspace
|
||||
uses: EmbarkStudios/cargo-deny-action@v2
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
name: "Check"
|
||||
|
||||
on:
|
||||
pull_request: {}
|
||||
merge_group: {}
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
# Check if CI can be skipped (for merge queue deduplication)
|
||||
skip-check:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
skip: ${{ steps.check.outputs.skip-check }}
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 🚦 Check if CI can be skipped
|
||||
id: check
|
||||
uses: cariad-tech/merge-queue-ci-skipper@cf80db21fc70244e36487acc531b3f1118889b0a
|
||||
|
||||
# Build the web app via the shared build workflow
|
||||
build:
|
||||
needs: skip-check
|
||||
if: needs.skip-check.outputs.skip != 'true'
|
||||
uses: ./.github/workflows/build.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
web: true
|
||||
merge_queue: ${{ github.event_name == 'merge_group' }}
|
||||
|
||||
# Run the Rust tests on the self-hosted native runner
|
||||
test:
|
||||
needs: skip-check
|
||||
if: needs.skip-check.outputs.skip != 'true'
|
||||
runs-on: [self-hosted, target/native]
|
||||
env:
|
||||
RUSTC_WRAPPER: /usr/bin/sccache
|
||||
CARGO_INCREMENTAL: 0
|
||||
SCCACHE_DIR: /var/lib/github-actions/.cache
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 🦀 Install Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
cache: false
|
||||
rustflags: ""
|
||||
|
||||
- name: 🦀 Fetch Rust dependencies
|
||||
run: cargo fetch --locked
|
||||
|
||||
- name: 🧪 Run Rust tests
|
||||
env:
|
||||
RUSTFLAGS: -Dwarnings
|
||||
run: mold -run cargo test --all-features
|
||||
|
||||
# Rust format check on GitHub runner
|
||||
rust-fmt:
|
||||
needs: skip-check
|
||||
if: needs.skip-check.outputs.skip != 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 🦀 Install Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
cache: false
|
||||
rustflags: ""
|
||||
components: rustfmt
|
||||
|
||||
- name: 🔬 Check Rust formatting
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
# License compatibility check on GitHub runner
|
||||
check-licenses:
|
||||
needs: skip-check
|
||||
if: needs.skip-check.outputs.skip != 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 📜 Check crate license compatibility for root workspace
|
||||
uses: EmbarkStudios/cargo-deny-action@v2
|
||||
with:
|
||||
command: check bans licenses sources
|
||||
|
||||
- name: 📜 Check crate license compatibility for /libraries/rawkit
|
||||
uses: EmbarkStudios/cargo-deny-action@v2
|
||||
with:
|
||||
command: check bans licenses sources
|
||||
manifest-path: libraries/rawkit/Cargo.toml
|
||||
@@ -0,0 +1,155 @@
|
||||
name: "CI"
|
||||
|
||||
on:
|
||||
pull_request: {}
|
||||
merge_group: {}
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
# Rust format check on GitHub runner
|
||||
rust-fmt:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🚦 Check if CI can be skipped
|
||||
id: skip-check
|
||||
uses: cariad-tech/merge-queue-ci-skipper@main
|
||||
|
||||
- name: 🦀 Install the latest Rust
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: rustfmt
|
||||
|
||||
- name: 🔬 Check Rust formatting
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
# License compatibility check on GitHub runner
|
||||
cargo-deny:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 📜 Check crate license compatibility for root workspace
|
||||
uses: EmbarkStudios/cargo-deny-action@v2
|
||||
with:
|
||||
command: check bans licenses sources
|
||||
|
||||
- name: 📜 Check crate license compatibility for /libraries/rawkit
|
||||
uses: EmbarkStudios/cargo-deny-action@v2
|
||||
with:
|
||||
command: check bans licenses sources
|
||||
manifest-path: libraries/rawkit/Cargo.toml
|
||||
|
||||
# Build the web app on the self-hosted wasm runner
|
||||
build:
|
||||
runs-on: [self-hosted, target/wasm]
|
||||
permissions:
|
||||
contents: write
|
||||
deployments: write
|
||||
pull-requests: write
|
||||
actions: write
|
||||
env:
|
||||
RUSTC_WRAPPER: /usr/bin/sccache
|
||||
CARGO_INCREMENTAL: 0
|
||||
SCCACHE_DIR: /var/lib/github-actions/.cache
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🚦 Check if CI can be skipped
|
||||
id: skip-check
|
||||
uses: cariad-tech/merge-queue-ci-skipper@main
|
||||
|
||||
- name: 🗑 Clear wasm-bindgen cache
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
run: rm -r ~/.cache/.wasm-pack || true
|
||||
|
||||
- name: 🟢 Install the latest Node.js
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'latest'
|
||||
|
||||
- name: 🚧 Install build dependencies
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
run: |
|
||||
cd frontend
|
||||
npm run setup
|
||||
|
||||
- name: 🦀 Install the latest Rust
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
run: |
|
||||
rustup update stable
|
||||
|
||||
- name: 🦀 Fetch Rust dependencies
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
run: |
|
||||
cargo fetch --locked
|
||||
|
||||
- name: 🌐 Build Graphite web code
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
mold -run npm run build
|
||||
|
||||
- name: 📤 Publish to Cloudflare Pages
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
uses: cloudflare/pages-action@1
|
||||
continue-on-error: true
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
projectName: graphite-dev
|
||||
directory: frontend/dist
|
||||
|
||||
- name: 👕 Lint Graphite web formatting
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
npm run lint
|
||||
|
||||
# Run the Rust tests on the self-hosted native runner
|
||||
test:
|
||||
runs-on: [self-hosted, target/native]
|
||||
env:
|
||||
RUSTC_WRAPPER: /usr/bin/sccache
|
||||
CARGO_INCREMENTAL: 0
|
||||
SCCACHE_DIR: /var/lib/github-actions/.cache
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🚦 Check if CI can be skipped
|
||||
id: skip-check
|
||||
uses: cariad-tech/merge-queue-ci-skipper@main
|
||||
|
||||
- name: 🦀 Install the latest Rust
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
run: |
|
||||
rustup update stable
|
||||
|
||||
- name: 🦀 Fetch Rust dependencies
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
run: |
|
||||
cargo fetch --locked
|
||||
|
||||
- name: 🧪 Run Rust tests
|
||||
if: steps.skip-check.outputs.skip-check != 'true'
|
||||
env:
|
||||
RUSTFLAGS: -Dwarnings
|
||||
run: |
|
||||
mold -run cargo test --all-features
|
||||
@@ -1,137 +1,159 @@
|
||||
# USAGE:
|
||||
# After reviewing the code, core team members may comment on a PR with `!build` followed by optional `<target>` and `<profile>` arguments.
|
||||
# This matches the syntax of the `cargo run build` CLI command, but allows platforms to be specified.
|
||||
#
|
||||
# `<target>`: `web` (default), `desktop` (all platforms), or `desktop:<platforms>` (subset of `windows+mac+linux`)
|
||||
# `<profile>`: `release` (default) or `debug`
|
||||
#
|
||||
# Examples:
|
||||
# - !build
|
||||
# - !build debug
|
||||
# - !build desktop
|
||||
# - !build desktop:windows+mac
|
||||
# - !build desktop:linux debug
|
||||
# After reviewing the code, core team members may comment on a PR with the exact text:
|
||||
# - `!build-dev` to build with debug symbols and optimizations disabled
|
||||
# - `!build-profiling` to build with debug symbols and optimizations enabled
|
||||
# - `!build` to build without debug symbols and optimizations enabled
|
||||
# The comment may not contain any other text, not even whitespace or newlines.
|
||||
name: "!build PR Command"
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types:
|
||||
- created
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
build:
|
||||
# Command should be limited to core team members (those in the organization) for security.
|
||||
# From the GitHub Actions docs:
|
||||
# author_association = 'MEMBER': Author is a member of the organization that owns the repository.
|
||||
if: >
|
||||
github.event.issue.pull_request &&
|
||||
github.event.comment.author_association == 'MEMBER' &&
|
||||
startsWith(github.event.comment.body, '!build')
|
||||
runs-on: ubuntu-latest
|
||||
(github.event.comment.body == '!build-dev' || github.event.comment.body == '!build-profiling' || github.event.comment.body == '!build')
|
||||
runs-on: self-hosted
|
||||
permissions:
|
||||
contents: read
|
||||
deployments: write
|
||||
pull-requests: write
|
||||
outputs:
|
||||
repo: ${{ steps.pr_info.outputs.repo }}
|
||||
ref: ${{ steps.pr_info.outputs.ref }}
|
||||
web: ${{ steps.pr_info.outputs.web }}
|
||||
windows: ${{ steps.pr_info.outputs.windows }}
|
||||
mac: ${{ steps.pr_info.outputs.mac }}
|
||||
linux: ${{ steps.pr_info.outputs.linux }}
|
||||
debug: ${{ steps.pr_info.outputs.debug }}
|
||||
env:
|
||||
RUSTC_WRAPPER: /usr/bin/sccache
|
||||
CARGO_INCREMENTAL: 0
|
||||
SCCACHE_DIR: /var/lib/github-actions/.cache
|
||||
|
||||
steps:
|
||||
- name: 🔎 Parse command, find branch, and set build flags
|
||||
id: pr_info
|
||||
- name: 🔎 Find branch for this PR
|
||||
id: commit_info
|
||||
run: |
|
||||
COMMENT="${{ github.event.comment.body }}"
|
||||
|
||||
# Split into space-separated words
|
||||
read -ra WORDS <<< "$COMMENT"
|
||||
|
||||
# First word must be "!build"
|
||||
if [[ "${WORDS[0]}" != "!build" ]]; then
|
||||
echo "::error::Expected comment to start with !build"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Initialize build flags (web defaults to true, matching the CLI default target)
|
||||
WEB="true"
|
||||
WINDOWS="false"
|
||||
MAC="false"
|
||||
LINUX="false"
|
||||
DEBUG="false"
|
||||
|
||||
# Parse target (optional, defaults to `web` if omitted)
|
||||
IDX=1
|
||||
case "${WORDS[$IDX]:-}" in
|
||||
# Target: `web` enables just the web build (already the default, but accepted explicitly)
|
||||
"web")
|
||||
((IDX++)) ;;
|
||||
# Target: `desktop` enables all three desktop platforms
|
||||
"desktop")
|
||||
WEB="false"; WINDOWS="true"; MAC="true"; LINUX="true"; ((IDX++)) ;;
|
||||
# Target: `desktop:<platforms>` enables a subset of desktop platforms, split by `+`
|
||||
desktop:*)
|
||||
WEB="false"
|
||||
PLATFORMS="${WORDS[$IDX]#desktop:}"
|
||||
IFS='+' read -ra PARTS <<< "$PLATFORMS"
|
||||
for PART in "${PARTS[@]}"; do
|
||||
case "$PART" in
|
||||
"windows") WINDOWS="true" ;;
|
||||
"mac") MAC="true" ;;
|
||||
"linux") LINUX="true" ;;
|
||||
*) echo "::error::Unrecognized platform: $PART"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
((IDX++))
|
||||
;;
|
||||
esac
|
||||
|
||||
# Parse profile (optional, defaults to `release` if omitted)
|
||||
case "${WORDS[$IDX]:-}" in
|
||||
"debug") DEBUG="true"; ((IDX++)) ;;
|
||||
"release") ((IDX++)) ;;
|
||||
esac
|
||||
|
||||
# Reject any unexpected trailing words
|
||||
if [[ $IDX -lt ${#WORDS[@]} ]]; then
|
||||
echo "::error::Unexpected argument: ${WORDS[$IDX]}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Write parsed build flags to job outputs
|
||||
echo "web=$WEB" >> $GITHUB_OUTPUT
|
||||
echo "windows=$WINDOWS" >> $GITHUB_OUTPUT
|
||||
echo "mac=$MAC" >> $GITHUB_OUTPUT
|
||||
echo "linux=$LINUX" >> $GITHUB_OUTPUT
|
||||
echo "debug=$DEBUG" >> $GITHUB_OUTPUT
|
||||
|
||||
# Fetch the PR's head branch and repo (needed for forked PRs where the code lives in another repo)
|
||||
RESPONSE=$(curl -L -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})
|
||||
echo "repo=$(echo $RESPONSE | jq -r '.head.repo.full_name')" >> $GITHUB_OUTPUT
|
||||
echo "ref=$(echo $RESPONSE | jq -r '.head.ref')" >> $GITHUB_OUTPUT
|
||||
REPO=$(echo $RESPONSE | jq -r '.head.repo.full_name')
|
||||
REF=$(echo $RESPONSE | jq -r '.head.ref')
|
||||
SHA=$(echo $RESPONSE | jq -r '.head.sha')
|
||||
echo "repo=$REPO" >> $GITHUB_OUTPUT
|
||||
echo "ref=$REF" >> $GITHUB_OUTPUT
|
||||
echo "sha=$SHA" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 💬 Edit comment with workflow run link
|
||||
uses: actions/github-script@v8
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ steps.commit_info.outputs.repo }}
|
||||
ref: ${{ steps.commit_info.outputs.ref }}
|
||||
|
||||
- name: 🗑 Clear wasm-bindgen cache
|
||||
continue-on-error: true
|
||||
run: rm -r ~/.cache/.wasm-pack
|
||||
|
||||
- name: 🟢 Install the latest Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "latest"
|
||||
|
||||
- name: 🚧 Install build dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm run setup
|
||||
|
||||
- name: 🦀 Install the latest Rust
|
||||
run: |
|
||||
echo "Initial system version:"
|
||||
rustc --version
|
||||
rustup update stable
|
||||
echo "Latest updated version:"
|
||||
rustc --version
|
||||
|
||||
- name: ✂ Replace template in <head> of index.html
|
||||
env:
|
||||
INDEX_HTML_HEAD_REPLACEMENT: ""
|
||||
run: |
|
||||
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
|
||||
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
|
||||
|
||||
- name: ⌨ Set build command based on comment
|
||||
id: build_command
|
||||
run: |
|
||||
if [[ "${{ github.event.comment.body }}" == "!build-dev" ]]; then
|
||||
echo "command=build-dev" >> $GITHUB_OUTPUT
|
||||
elif [[ "${{ github.event.comment.body }}" == "!build-profiling" ]]; then
|
||||
echo "command=build-profiling" >> $GITHUB_OUTPUT
|
||||
elif [[ "${{ github.event.comment.body }}" == "!build" ]]; then
|
||||
echo "command=build" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Failed to detect if the build command written in the comment should have been '!build-dev', '!build-profiling', or '!build'" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: 💬 Comment Actions run link
|
||||
id: comment_actions_run_link
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.updateComment({
|
||||
comment_id: ${{ github.event.comment.id }},
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: '${{ github.event.comment.body }} ([Run ID ' + context.runId + '](https://github.com/GraphiteEditor/Graphite/actions/runs/' + context.runId + '))'
|
||||
body: '!build ([Run ID ' + context.runId + '](https://github.com/GraphiteEditor/Graphite/actions/runs/' + context.runId + '))'
|
||||
});
|
||||
|
||||
invoke-build:
|
||||
needs: setup
|
||||
uses: ./.github/workflows/build.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
web: ${{ needs.setup.outputs.web == 'true' }}
|
||||
windows: ${{ needs.setup.outputs.windows == 'true' }}
|
||||
mac: ${{ needs.setup.outputs.mac == 'true' }}
|
||||
linux: ${{ needs.setup.outputs.linux == 'true' }}
|
||||
debug: ${{ needs.setup.outputs.debug == 'true' }}
|
||||
checkout_repo: ${{ needs.setup.outputs.repo }}
|
||||
checkout_ref: ${{ needs.setup.outputs.ref }}
|
||||
pr_number: ${{ github.event.issue.number }}
|
||||
- name: 🌐 Build Graphite web code
|
||||
env:
|
||||
NODE_ENV: production
|
||||
if: ${{ success() || failure()}}
|
||||
run: |
|
||||
cd frontend
|
||||
mold -run npm run ${{ steps.build_command.outputs.command }}
|
||||
|
||||
- name: ❗ Warn on build failure
|
||||
if: ${{ failure() }}
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: 'The build process has failed. Please check the [build logs](https://github.com/GraphiteEditor/Graphite/actions/runs/' + context.runId + ') for details.'
|
||||
});
|
||||
|
||||
- name: 📤 Publish to Cloudflare Pages
|
||||
id: cloudflare
|
||||
uses: cloudflare/pages-action@1
|
||||
continue-on-error: true
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
projectName: graphite-dev
|
||||
directory: frontend/dist
|
||||
|
||||
- name: ❗ Warn on publish failure
|
||||
if: ${{ failure() }}
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: 'The deployment to Cloudflare Pages has failed. Please check the [build logs](https://github.com/GraphiteEditor/Graphite/actions/runs/' + context.runId + ') for details.
|
||||
});
|
||||
|
||||
- name: 💬 Comment build link
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: '| 📦 **Build Complete for** ${{ steps.commit_info.outputs.sha }} |\n|-|\n| ${{ steps.cloudflare.outputs.url }} |'
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
name: "Clippy Check"
|
||||
name: Clippy Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Delete previous comments
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
|
||||
- name: Comment PR
|
||||
if: steps.clippy.outputs.CLIPPY_ISSUES_FOUND == 'true'
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: "Profiling Changes"
|
||||
name: Profiling Changes
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -35,14 +35,15 @@ jobs:
|
||||
|
||||
- name: Cache iai-callgrind binary
|
||||
id: cache-iai
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cargo/bin/iai-callgrind-runner
|
||||
key: ${{ runner.os }}-iai-callgrind-runner-0.16.1
|
||||
|
||||
- name: Install iai-callgrind
|
||||
if: steps.cache-iai.outputs.cache-hit != 'true'
|
||||
run: cargo install [email protected]
|
||||
run: |
|
||||
cargo install [email protected]
|
||||
|
||||
- name: Checkout master branch
|
||||
run: |
|
||||
@@ -64,7 +65,7 @@ jobs:
|
||||
|
||||
- name: Cache benchmark baselines
|
||||
id: cache-benchmark-baselines
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: target/iai
|
||||
key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.cpu-info.outputs.cpu-hash }}-benchmark-baselines-master-${{ steps.master-sha.outputs.sha }}
|
||||
@@ -83,7 +84,8 @@ jobs:
|
||||
cargo bench --bench run_cached_iai -- --save-baseline=master
|
||||
|
||||
- name: Checkout PR branch
|
||||
run: git checkout ${{ github.event.pull_request.head.sha }}
|
||||
run: |
|
||||
git checkout ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Run PR benchmarks
|
||||
run: |
|
||||
@@ -98,7 +100,7 @@ jobs:
|
||||
- name: Make old comments collapsed by default
|
||||
# Only run if we have write permissions (not a fork)
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
@@ -124,7 +126,7 @@ jobs:
|
||||
|
||||
- name: Analyze profiling changes
|
||||
id: analyze
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
@@ -183,7 +185,7 @@ jobs:
|
||||
|
||||
- name: Comment PR
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
@@ -333,7 +335,7 @@ jobs:
|
||||
|
||||
- name: Fail on significant regressions
|
||||
if: steps.analyze.outputs.has-significant-changes == 'true'
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const regressionDetails = JSON.parse('${{ steps.analyze.outputs.regression-details }}');
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
name: "Deploy Master"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="dev.graphite.art" data-api="https://graphite.art/visit/event" src="https://graphite.art/visit/script.hash.js"></script>
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: [self-hosted, target/wasm]
|
||||
permissions:
|
||||
contents: write
|
||||
deployments: write
|
||||
actions: write
|
||||
env:
|
||||
RUSTC_WRAPPER: /usr/bin/sccache
|
||||
CARGO_INCREMENTAL: 0
|
||||
SCCACHE_DIR: /var/lib/github-actions/.cache
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🗑 Clear wasm-bindgen cache
|
||||
run: rm -r ~/.cache/.wasm-pack || true
|
||||
|
||||
- name: 🟢 Install the latest Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'latest'
|
||||
|
||||
- name: 🚧 Install build dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm run setup
|
||||
|
||||
- name: 🦀 Install the latest Rust
|
||||
run: |
|
||||
rustup update stable
|
||||
|
||||
- name: ✂ Replace template in <head> of index.html
|
||||
run: |
|
||||
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
|
||||
|
||||
- name: 🌐 Build Graphite web code
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: |
|
||||
cd frontend
|
||||
mold -run npm run build
|
||||
|
||||
- name: 📤 Publish to Cloudflare Pages
|
||||
id: cloudflare
|
||||
uses: cloudflare/pages-action@1
|
||||
continue-on-error: true
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
projectName: graphite-dev
|
||||
directory: frontend/dist
|
||||
|
||||
- name: 💬 Comment build link URL to commit hash page on GitHub
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh api \
|
||||
-X POST \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
/repos/${{ github.repository }}/commits/$(git rev-parse HEAD)/comments \
|
||||
-f body="| 📦 **Build Complete for** $(git rev-parse HEAD) |
|
||||
|-|
|
||||
| ${{ steps.cloudflare.outputs.url }} |"
|
||||
|
||||
- name: 📃 Generate code documentation info for website
|
||||
run: |
|
||||
cd tools/editor-message-tree
|
||||
cargo run
|
||||
cd ../..
|
||||
mkdir -p artifacts-generated
|
||||
mv website/generated/hierarchical_message_system_tree.txt artifacts-generated/hierarchical_message_system_tree.txt
|
||||
|
||||
- name: 💿 Obtain cache of auto-generated code docs artifacts, to check if they've changed
|
||||
id: cache-website-code-docs
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: artifacts
|
||||
key: website-code-docs
|
||||
|
||||
- name: 🔍 Check if auto-generated code docs artifacts changed
|
||||
id: website-code-docs-changed
|
||||
run: |
|
||||
if ! diff --brief --recursive artifacts-generated artifacts; then
|
||||
echo "Auto-generated code docs artifacts have changed."
|
||||
rm -rf artifacts
|
||||
mv artifacts-generated artifacts
|
||||
echo "changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Auto-generated code docs artifacts have not changed."
|
||||
rm -rf artifacts
|
||||
rm -rf artifacts-generated
|
||||
fi
|
||||
|
||||
- name: 💾 Save cache of auto-generated code docs artifacts
|
||||
if: steps.website-code-docs-changed.outputs.changed == 'true'
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
path: artifacts
|
||||
key: ${{ steps.cache-website-code-docs.outputs.cache-primary-key }}
|
||||
|
||||
- name: ♻️ Trigger website rebuild if the auto-generated code docs artifacts have changed
|
||||
if: steps.website-code-docs-changed.outputs.changed == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
rm -rf artifacts
|
||||
gh workflow run website.yml --ref master
|
||||
@@ -25,16 +25,16 @@ jobs:
|
||||
SCCACHE_DIR: /var/lib/github-actions/.cache
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🦀 Install Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
cache: false
|
||||
rustflags: ""
|
||||
- name: 🦀 Install the latest Rust
|
||||
run: |
|
||||
echo "Initial system version:"
|
||||
rustc --version
|
||||
rustup update stable
|
||||
echo "Latest updated version:"
|
||||
rustc --version
|
||||
|
||||
- name: 📦 Run sccache-cache
|
||||
uses: mozilla-actions/[email protected]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: "Provide Shaders"
|
||||
name: Provide Shaders
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -12,19 +12,14 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
- name: ❄ Install Nix
|
||||
uses: DeterminateSystems/nix-installer-action@main
|
||||
- name: Build graphene raster nodes shaders
|
||||
run: nix build .nix#graphite-raster-nodes-shaders && cp result raster_nodes_shaders_entrypoint.wgsl
|
||||
|
||||
- name: 💾 Set up Nix cache
|
||||
uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
- name: 🏗 Build graphene raster nodes shaders
|
||||
run: nix build .#graphite-raster-nodes-shaders && cp result raster_nodes_shaders_entrypoint.wgsl
|
||||
|
||||
- name: 📤 Upload graphene raster nodes shaders to artifacts repository
|
||||
- name: Upload graphene raster nodes shaders to artifacts repository
|
||||
run: |
|
||||
bash .github/workflows/scripts/artifact-upload.bash \
|
||||
${{ vars.ARTIFACTS_REPO_OWNER }} \
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
FROM ubuntu:24.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# System dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
cmake \
|
||||
curl \
|
||||
git \
|
||||
jq \
|
||||
libssl-dev \
|
||||
lsb-release \
|
||||
mold \
|
||||
pkg-config \
|
||||
sudo \
|
||||
unzip \
|
||||
wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install sccache to /usr/bin (CI expects it there for RUSTC_WRAPPER)
|
||||
ARG SCCACHE_VERSION=0.9.1
|
||||
RUN ARCH=$(uname -m) && \
|
||||
curl -fsSL "https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-${ARCH}-unknown-linux-musl.tar.gz" \
|
||||
| tar xz --strip-components=1 -C /usr/bin/ "sccache-v${SCCACHE_VERSION}-${ARCH}-unknown-linux-musl/sccache" && \
|
||||
chmod +x /usr/bin/sccache
|
||||
|
||||
# Install Node.js LTS
|
||||
ARG NODE_MAJOR=22
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - && \
|
||||
apt-get install -y --no-install-recommends nodejs && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create runner user
|
||||
RUN useradd -m -s /bin/bash runner && \
|
||||
echo "runner ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/runner
|
||||
|
||||
# Create cache directories with correct ownership
|
||||
RUN mkdir -p /var/lib/github-actions/.cache && \
|
||||
chown -R runner:runner /var/lib/github-actions
|
||||
|
||||
USER runner
|
||||
WORKDIR /home/runner
|
||||
|
||||
# Install Rust stable + wasm target
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile default && \
|
||||
. "$HOME/.cargo/env" && \
|
||||
rustup target add wasm32-unknown-unknown && \
|
||||
rustup component add clippy rustfmt
|
||||
|
||||
ENV PATH="/home/runner/.cargo/bin:${PATH}"
|
||||
|
||||
# Install cargo tools required by the project
|
||||
# wasm-bindgen-cli is pinned to match the version in Cargo.toml (=0.2.100)
|
||||
RUN cargo install --locked [email protected] && \
|
||||
cargo install --locked wasm-pack && \
|
||||
cargo install --locked cargo-about
|
||||
|
||||
# Environment variables matching CI configuration
|
||||
ENV RUSTC_WRAPPER=/usr/bin/sccache
|
||||
ENV CARGO_INCREMENTAL=0
|
||||
ENV SCCACHE_DIR=/var/lib/github-actions/.cache
|
||||
|
||||
# Install GitHub Actions runner
|
||||
ARG RUNNER_VERSION=2.322.0
|
||||
RUN ARCH=$(uname -m | sed 's/x86_64/x64/' | sed 's/aarch64/arm64/') && \
|
||||
curl -fsSL "https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz" \
|
||||
| tar xz -C /home/runner
|
||||
|
||||
# Entrypoint script: configure and start the runner
|
||||
COPY --chown=runner:runner <<'ENTRYPOINT' /home/runner/entrypoint.sh
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
RUNNER_NAME="${RUNNER_NAME:-$(hostname)}"
|
||||
RUNNER_LABELS="${RUNNER_LABELS:-target/wasm,target/native}"
|
||||
RUNNER_WORKDIR="${RUNNER_WORKDIR:-/home/runner/_work}"
|
||||
|
||||
# Configure the runner if not already configured
|
||||
if [ ! -f /home/runner/.runner ]; then
|
||||
/home/runner/config.sh \
|
||||
--unattended \
|
||||
--url "${GITHUB_URL}" \
|
||||
--token "${RUNNER_TOKEN}" \
|
||||
--name "${RUNNER_NAME}" \
|
||||
--labels "${RUNNER_LABELS}" \
|
||||
--work "${RUNNER_WORKDIR}" \
|
||||
--replace
|
||||
fi
|
||||
|
||||
# Run with automatic cleanup on container stop
|
||||
exec /home/runner/run.sh
|
||||
ENTRYPOINT
|
||||
RUN chmod +x /home/runner/entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/home/runner/entrypoint.sh"]
|
||||
Executable
+124
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
IMAGE_NAME="graphite-github-actions-runner"
|
||||
GITHUB_URL="https://github.com/GraphiteEditor/Graphite"
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $0 [options]
|
||||
|
||||
Spawn self-hosted GitHub Actions runners for Graphite.
|
||||
|
||||
Required:
|
||||
-t TOKEN GitHub runner registration token
|
||||
-p PREFIX Runner name prefix
|
||||
|
||||
Optional:
|
||||
-n COUNT Number of target/native runners to create (default: 1)
|
||||
-w COUNT Number of target/wasm runners to create (default: 1)
|
||||
-u URL GitHub repository URL (default: $GITHUB_URL)
|
||||
-i IMAGE Container image name (default: $IMAGE_NAME)
|
||||
-b Build the image before starting runners
|
||||
-d Tear down existing runners matching the prefix first
|
||||
-h Show this help message
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
NATIVE_COUNT=1
|
||||
WASM_COUNT=1
|
||||
TOKEN=""
|
||||
PREFIX=""
|
||||
BUILD=false
|
||||
TEARDOWN=false
|
||||
|
||||
while getopts "t:p:n:w:u:i:bdh" opt; do
|
||||
case $opt in
|
||||
t) TOKEN="$OPTARG" ;;
|
||||
p) PREFIX="$OPTARG" ;;
|
||||
n) NATIVE_COUNT="$OPTARG" ;;
|
||||
w) WASM_COUNT="$OPTARG" ;;
|
||||
u) GITHUB_URL="$OPTARG" ;;
|
||||
i) IMAGE_NAME="$OPTARG" ;;
|
||||
b) BUILD=true ;;
|
||||
d) TEARDOWN=true ;;
|
||||
h) usage ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$PREFIX" ]; then
|
||||
echo "Error: -p PREFIX is required"
|
||||
usage
|
||||
fi
|
||||
|
||||
teardown() {
|
||||
local pattern="$IMAGE_NAME-${PREFIX}-"
|
||||
echo "Tearing down containers matching: ${pattern}*"
|
||||
for cid in $(podman ps -a --filter "name=${pattern}" --format '{{.ID}}' 2>/dev/null); do
|
||||
name=$(podman inspect --format '{{.Name}}' "$cid")
|
||||
echo " Stopping and removing $name"
|
||||
podman rm -f "$cid"
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$TEARDOWN" = true ]; then
|
||||
teardown
|
||||
if [ -z "$TOKEN" ]; then
|
||||
echo "Teardown complete."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$TOKEN" ]; then
|
||||
echo "Error: -t TOKEN is required to create runners"
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ "$BUILD" = true ]; then
|
||||
echo "Building image: $IMAGE_NAME"
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
podman build -t "$IMAGE_NAME" -f "$SCRIPT_DIR/containerfile" "$SCRIPT_DIR/.."
|
||||
echo ""
|
||||
fi
|
||||
|
||||
start_runner() {
|
||||
local target="$1" # native or wasm
|
||||
local index="$2"
|
||||
|
||||
local name="${IMAGE_NAME}-${PREFIX}-${target}-${index}"
|
||||
local runner_name="${PREFIX}-${target}-${index}"
|
||||
local label="target/${target}"
|
||||
|
||||
# Each runner gets its own sccache volume for isolation
|
||||
local cache_vol="${name}-cache"
|
||||
|
||||
echo "Starting runner: $name (label: $label)"
|
||||
podman run -d \
|
||||
--name "$name" \
|
||||
--restart unless-stopped \
|
||||
-v "${cache_vol}:/var/lib/github-actions/.cache" \
|
||||
-e RUNNER_NAME="$runner_name" \
|
||||
-e RUNNER_LABELS="$label" \
|
||||
-e GITHUB_URL="$GITHUB_URL" \
|
||||
-e RUNNER_TOKEN="$TOKEN" \
|
||||
"$IMAGE_NAME"
|
||||
|
||||
echo " -> $name started (volume: $cache_vol)"
|
||||
}
|
||||
|
||||
echo "Creating $NATIVE_COUNT native runner(s) and $WASM_COUNT wasm runner(s)"
|
||||
echo ""
|
||||
|
||||
for i in $(seq 0 $((NATIVE_COUNT - 1))); do
|
||||
start_runner "native" "$i"
|
||||
done
|
||||
|
||||
for i in $(seq 0 $((WASM_COUNT - 1))); do
|
||||
start_runner "wasm" "$i"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "All runners started. Verify with: podman ps --filter name=$IMAGE_NAME"
|
||||
@@ -1,7 +1,6 @@
|
||||
name: "Website"
|
||||
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
@@ -10,6 +9,7 @@ on:
|
||||
pull_request:
|
||||
paths:
|
||||
- website/**
|
||||
workflow_dispatch: {}
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
INDEX_HTML_HEAD_INCLUSION: <script defer data-domain="graphite.art" data-api="/visit/event" src="/visit/script.hash.js"></script>
|
||||
@@ -23,13 +23,16 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: 📥 Clone repository
|
||||
uses: actions/checkout@v6
|
||||
- name: 📥 Clone and checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: 🟢 Install Node.js
|
||||
uses: actions/setup-node@v6
|
||||
# We can remove this step once `ubuntu-latest` has Node.js 22 or newer for its native TypeScript support. See:
|
||||
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
|
||||
# https://nodejs.org/en/learn/typescript/run-natively
|
||||
- name: 📦 Install the latest Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
node-version: "latest"
|
||||
|
||||
- name: 🕸 Install Zola
|
||||
uses: taiki-e/install-action@v2
|
||||
@@ -49,31 +52,58 @@ jobs:
|
||||
# Remove the INDEX_HTML_HEAD_INCLUSION environment variable for build links (not master deploys)
|
||||
git rev-parse --abbrev-ref HEAD | grep master > /dev/null || export INDEX_HTML_HEAD_INCLUSION=""
|
||||
|
||||
- name: 🦀 Produce auto-generated code docs data
|
||||
run: |
|
||||
rustup update stable
|
||||
cargo run -p crate-hierarchy-viz -- website/generated
|
||||
cargo run -p editor-message-tree -- website/generated
|
||||
- name: 💿 Obtain cache of auto-generated code docs artifacts
|
||||
id: cache-website-code-docs
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: artifacts
|
||||
key: website-code-docs
|
||||
|
||||
- name: 🔧 Install website npm dependencies
|
||||
- name: 📁 Fallback in case auto-generated code docs artifacts weren't cached
|
||||
if: steps.cache-website-code-docs.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
echo "🦀 Initial system version of Rust:"
|
||||
rustc --version
|
||||
rustup update stable
|
||||
echo "🦀 Latest updated version of Rust:"
|
||||
rustc --version
|
||||
cd tools/editor-message-tree
|
||||
cargo run
|
||||
cd ../..
|
||||
mkdir artifacts
|
||||
mv website/generated/hierarchical_message_system_tree.txt artifacts/hierarchical_message_system_tree.txt
|
||||
|
||||
- name: 🚚 Move `artifacts` contents to website/generated
|
||||
run: |
|
||||
mkdir -p website/generated
|
||||
mv artifacts/* website/generated/
|
||||
|
||||
- name: 🔧 Build auto-generated code docs artifacts into HTML
|
||||
run: |
|
||||
cd website
|
||||
npm ci
|
||||
npm run generate-editor-structure
|
||||
|
||||
- name: 📃 Generate node catalog documentation
|
||||
run: cargo run -p node-docs -- website/content/learn/node-catalog
|
||||
run: |
|
||||
cd tools/node-docs
|
||||
cargo run
|
||||
|
||||
- name: 🌐 Build Graphite website with Zola
|
||||
env:
|
||||
MODE: prod
|
||||
run: |
|
||||
cd website
|
||||
npm run check
|
||||
npm ci
|
||||
npm run lint
|
||||
zola --config config.toml build --minify
|
||||
|
||||
- name: 📤 Publish to Cloudflare Pages
|
||||
id: cloudflare
|
||||
uses: cloudflare/pages-action@1
|
||||
continue-on-error: true
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
run: npx wrangler@3 pages deploy "website/public" --project-name="graphite-website" --commit-dirty=true
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
projectName: graphite-website
|
||||
directory: website/public
|
||||
@@ -1,83 +0,0 @@
|
||||
inputs:
|
||||
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
forAllSystems = f: inputs.nixpkgs.lib.genAttrs systems (system: f system);
|
||||
args =
|
||||
system:
|
||||
(
|
||||
let
|
||||
lib = inputs.nixpkgs.lib // {
|
||||
call = p: import p args;
|
||||
};
|
||||
|
||||
pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import inputs.rust-overlay) ];
|
||||
};
|
||||
|
||||
info = {
|
||||
pname = "graphite";
|
||||
version = "unstable";
|
||||
src = inputs.nixpkgs.lib.cleanSourceWith {
|
||||
src = ./..;
|
||||
filter = path: type: !(type == "directory" && builtins.baseNameOf path == ".nix");
|
||||
};
|
||||
cargoVendored = deps.crane.lib.vendorCargoDeps { inherit (info) src; };
|
||||
};
|
||||
|
||||
deps = {
|
||||
crane = lib.call ./deps/crane.nix;
|
||||
cef = lib.call ./deps/cef.nix;
|
||||
rustGPU = lib.call ./deps/rust-gpu.nix;
|
||||
};
|
||||
|
||||
args = {
|
||||
inherit system;
|
||||
inherit (inputs) self;
|
||||
inherit inputs;
|
||||
inherit pkgs;
|
||||
inherit lib;
|
||||
inherit info;
|
||||
inherit deps;
|
||||
}
|
||||
// inputs;
|
||||
in
|
||||
args
|
||||
);
|
||||
withArgs = f: forAllSystems (system: f (args system));
|
||||
in
|
||||
{
|
||||
packages = withArgs (
|
||||
{ lib, ... }:
|
||||
rec {
|
||||
default = graphite;
|
||||
graphite = (lib.call ./pkgs/graphite.nix) { };
|
||||
graphite-dev = (lib.call ./pkgs/graphite.nix) { dev = true; };
|
||||
graphite-raster-nodes-shaders = lib.call ./pkgs/graphite-raster-nodes-shaders.nix;
|
||||
graphite-branding = lib.call ./pkgs/graphite-branding.nix;
|
||||
graphite-bundle = (lib.call ./pkgs/graphite-bundle.nix) { };
|
||||
graphite-dev-bundle = (lib.call ./pkgs/graphite-bundle.nix) { graphite = graphite-dev; };
|
||||
graphite-flatpak-manifest = (lib.call ./pkgs/graphite-flatpak-manifest.nix) { };
|
||||
graphite-dev-flatpak-manifest = (lib.call ./pkgs/graphite-flatpak-manifest.nix) { graphite-bundle = graphite-dev-bundle; };
|
||||
|
||||
# TODO: graphene-cli = lib.call ./pkgs/graphene-cli.nix;
|
||||
|
||||
tools = {
|
||||
third-party-licenses = lib.call ./pkgs/tools/third-party-licenses.nix;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
devShells = withArgs (
|
||||
{ lib, ... }:
|
||||
{
|
||||
default = lib.call ./dev.nix;
|
||||
}
|
||||
);
|
||||
|
||||
formatter = withArgs ({ pkgs, ... }: pkgs.nixfmt-tree);
|
||||
}
|
||||
Generated
+15
@@ -15,6 +15,20 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"locked": {
|
||||
"lastModified": 1733328505,
|
||||
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
|
||||
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||
"revCount": 69,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1770197578,
|
||||
@@ -34,6 +48,7 @@
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
# This is a helper file for people using NixOS as their operating system.
|
||||
# If you don't know what this file does, you can safely ignore it.
|
||||
# This file defines the reproducible development environment for the project.
|
||||
#
|
||||
# Development Environment:
|
||||
# - Provides all necessary tools for Rust/Wasm development
|
||||
# - Includes dependencies for desktop app development
|
||||
# - Sets up profiling and debugging tools
|
||||
# - Configures mold as the default linker for faster builds
|
||||
#
|
||||
# Usage:
|
||||
# - Development shell: `nix develop .nix` from the project root
|
||||
# - Run in dev shell with direnv: add `use flake` to .envrc
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
crane.url = "github:ipetkov/crane";
|
||||
|
||||
# This is used to provide a identical development shell at `shell.nix` for users that do not use flakes
|
||||
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs:
|
||||
(
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
forAllSystems = f: inputs.nixpkgs.lib.genAttrs systems (system: f system);
|
||||
args =
|
||||
system:
|
||||
(
|
||||
let
|
||||
lib = inputs.nixpkgs.lib // {
|
||||
call = p: import p args;
|
||||
};
|
||||
|
||||
pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import inputs.rust-overlay) ];
|
||||
};
|
||||
|
||||
info = {
|
||||
pname = "graphite";
|
||||
version = "unstable";
|
||||
src = inputs.nixpkgs.lib.cleanSourceWith {
|
||||
src = ./..;
|
||||
filter = path: type: !(type == "directory" && builtins.baseNameOf path == ".nix");
|
||||
};
|
||||
cargoVendored = deps.crane.lib.vendorCargoDeps { inherit (info) src; };
|
||||
};
|
||||
|
||||
deps = {
|
||||
crane = lib.call ./deps/crane.nix;
|
||||
cef = lib.call ./deps/cef.nix;
|
||||
rustGPU = lib.call ./deps/rust-gpu.nix;
|
||||
};
|
||||
|
||||
args = {
|
||||
inherit system;
|
||||
inherit (inputs) self;
|
||||
inherit inputs;
|
||||
inherit pkgs;
|
||||
inherit lib;
|
||||
inherit info;
|
||||
inherit deps;
|
||||
}
|
||||
// inputs;
|
||||
in
|
||||
args
|
||||
);
|
||||
withArgs = f: forAllSystems (system: f (args system));
|
||||
in
|
||||
{
|
||||
packages = withArgs (
|
||||
{ lib, ... }:
|
||||
rec {
|
||||
default = graphite;
|
||||
graphite = (lib.call ./pkgs/graphite.nix) { };
|
||||
graphite-dev = (lib.call ./pkgs/graphite.nix) { dev = true; };
|
||||
graphite-raster-nodes-shaders = lib.call ./pkgs/graphite-raster-nodes-shaders.nix;
|
||||
graphite-branding = lib.call ./pkgs/graphite-branding.nix;
|
||||
graphite-bundle = lib.call ./pkgs/graphite-bundle.nix;
|
||||
graphite-flatpak-manifest = lib.call ./pkgs/graphite-flatpak-manifest.nix;
|
||||
|
||||
# TODO: graphene-cli = lib.call ./pkgs/graphene-cli.nix;
|
||||
|
||||
tools = {
|
||||
third-party-licenses = lib.call ./pkgs/tools/third-party-licenses.nix;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
devShells = withArgs (
|
||||
{ lib, ... }:
|
||||
{
|
||||
default = lib.call ./dev.nix;
|
||||
}
|
||||
);
|
||||
|
||||
formatter = withArgs ({ pkgs, ... }: pkgs.nixfmt-tree);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -4,9 +4,6 @@
|
||||
system,
|
||||
...
|
||||
}:
|
||||
{
|
||||
graphite ? self.packages.${system}.graphite,
|
||||
}:
|
||||
let
|
||||
bundle =
|
||||
{
|
||||
@@ -16,6 +13,7 @@ let
|
||||
}:
|
||||
(
|
||||
let
|
||||
graphite = self.packages.${system}.graphite;
|
||||
tar = if compression == null then archive else true;
|
||||
nameArchiveSuffix = if tar then ".tar" else "";
|
||||
nameCompressionSuffix = if compression == null then "" else "." + compression;
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
system,
|
||||
...
|
||||
}:
|
||||
{
|
||||
graphite-bundle ? self.packages.${system}.graphite-bundle,
|
||||
}:
|
||||
|
||||
(pkgs.formats.json { }).generate "art.graphite.Graphite.json" {
|
||||
app-id = "art.graphite.Graphite";
|
||||
@@ -33,7 +30,7 @@
|
||||
sources = [
|
||||
{
|
||||
type = "archive";
|
||||
path = graphite-bundle.tar;
|
||||
path = self.packages.${system}.graphite-bundle.tar;
|
||||
strip-components = 0;
|
||||
}
|
||||
];
|
||||
|
||||
@@ -32,7 +32,7 @@ let
|
||||
];
|
||||
buildInputs = [ pkgs.openssl ];
|
||||
env.CARGO_PROFILE = if dev then "dev" else "release";
|
||||
cargoExtraArgs = "--target wasm32-unknown-unknown -p graphite-wasm-wrapper --no-default-features --features native";
|
||||
cargoExtraArgs = "--target wasm32-unknown-unknown -p graphite-wasm --no-default-features --features native";
|
||||
doCheck = false;
|
||||
};
|
||||
resources = deps.crane.lib.buildPackage (
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# This is a helper file for people using NixOS as their operating system.
|
||||
# If you don't know what this file does, you can safely ignore it.
|
||||
|
||||
# If you are using Nix as your package manager, you can run 'nix-shell .nix'
|
||||
# in the root directory of the project and Nix will open a bash shell
|
||||
# with all the packages needed to build and run Graphite installed.
|
||||
# A shell.nix file is used in the Nix ecosystem to define a development
|
||||
# environment with specific dependencies. When you enter a Nix shell using
|
||||
# this file, it ensures that all the specified tools and libraries are
|
||||
# available regardless of the host system's configuration. This provides
|
||||
# a reproducible development environment across different machines and developers.
|
||||
|
||||
# You can enter the Nix shell and run Graphite like normal with:
|
||||
# > npm start
|
||||
# Or you can run it like this without needing to first enter the Nix shell:
|
||||
# > nix-shell .nix --command "npm start"
|
||||
|
||||
# Uses flake compat to provide a development shell that is identical to the one defined in the flake
|
||||
(import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
nodeName = lock.nodes.root.inputs.flake-compat;
|
||||
in
|
||||
fetchTarball {
|
||||
url = lock.nodes.${nodeName}.locked.url;
|
||||
sha256 = lock.nodes.${nodeName}.locked.narHash;
|
||||
}
|
||||
) { src = ./.; }).shellNix
|
||||
Vendored
+14
-1
@@ -39,12 +39,25 @@
|
||||
"rust-analyzer.check.command": "clippy",
|
||||
"rust-analyzer.cargo.allTargets": false,
|
||||
"rust-analyzer.procMacro.ignored": {
|
||||
"serde_derive": ["Serialize", "Deserialize"]
|
||||
"serde_derive": ["Serialize", "Deserialize"],
|
||||
"specta_macros": ["Type"] // Disabled because of: https://github.com/specta-rs/specta/issues/387
|
||||
},
|
||||
// ESLint config
|
||||
"eslint.format.enable": true,
|
||||
"eslint.workingDirectories": ["./frontend", "./website"],
|
||||
"eslint.validate": ["javascript", "typescript", "svelte"],
|
||||
// Svelte config
|
||||
"svelte.plugin.svelte.compilerWarnings": {
|
||||
"css-unused-selector": "ignore", // NOTICE: Keep this list in sync with the list in `frontend/vite.config.ts`
|
||||
"vite-plugin-svelte-css-no-scopable-elements": "ignore", // NOTICE: Keep this list in sync with the list in `frontend/vite.config.ts`
|
||||
"a11y-no-static-element-interactions": "ignore", // NOTICE: Keep this list in sync with the list in `frontend/vite.config.ts`
|
||||
"a11y-no-noninteractive-element-interactions": "ignore", // NOTICE: Keep this list in sync with the list in `frontend/vite.config.ts`
|
||||
"a11y-click-events-have-key-events": "ignore", // NOTICE: Keep this list in sync with the list in `frontend/vite.config.ts`
|
||||
"a11y_consider_explicit_label": "ignore", // NOTICE: Keep this list in sync with the list in `frontend/vite.config.ts`
|
||||
"a11y_click_events_have_key_events": "ignore", // NOTICE: Keep this list in sync with the list in `frontend/vite.config.ts`
|
||||
"a11y_no_noninteractive_element_interactions": "ignore", // NOTICE: Keep this list in sync with the list in `frontend/vite.config.ts`
|
||||
"a11y_no_static_element_interactions": "ignore" // NOTICE: Keep this list in sync with the list in `frontend/vite.config.ts`
|
||||
},
|
||||
// Git Graph config
|
||||
"git-graph.repository.fetchAndPrune": true,
|
||||
"git-graph.repository.showRemoteHeads": false,
|
||||
|
||||
Generated
+619
-142
File diff suppressed because it is too large.
Load diff
+16
-11
@@ -8,8 +8,9 @@ members = [
|
||||
"desktop/platform/mac",
|
||||
"desktop/platform/win",
|
||||
"editor",
|
||||
"frontend/wrapper",
|
||||
"frontend/wasm",
|
||||
"libraries/dyn-any",
|
||||
"libraries/path-bool",
|
||||
"libraries/math-parser",
|
||||
"node-graph/libraries/*",
|
||||
"node-graph/nodes/*",
|
||||
@@ -22,7 +23,6 @@ members = [
|
||||
"node-graph/node-macro",
|
||||
"node-graph/preprocessor",
|
||||
"proc-macros",
|
||||
"tools/cargo-run",
|
||||
"tools/crate-hierarchy-viz",
|
||||
"tools/third-party-licenses",
|
||||
"tools/editor-message-tree",
|
||||
@@ -30,16 +30,17 @@ members = [
|
||||
]
|
||||
default-members = [
|
||||
"editor",
|
||||
"frontend/wrapper",
|
||||
"frontend/wasm",
|
||||
"libraries/dyn-any",
|
||||
"libraries/path-bool",
|
||||
"libraries/math-parser",
|
||||
"node-graph/graph-craft",
|
||||
"node-graph/graphene-cli",
|
||||
"node-graph/interpreted-executor",
|
||||
"node-graph/node-macro",
|
||||
"node-graph/preprocessor",
|
||||
# blocked by https://github.com/rust-lang/cargo/issues/16000
|
||||
# "proc-macros",
|
||||
"tools/cargo-run",
|
||||
]
|
||||
resolver = "2"
|
||||
|
||||
@@ -65,6 +66,7 @@ dyn-any = { path = "libraries/dyn-any", features = [
|
||||
] }
|
||||
preprocessor = { path = "node-graph/preprocessor" }
|
||||
math-parser = { path = "libraries/math-parser" }
|
||||
path-bool = { path = "libraries/path-bool" }
|
||||
graphene-application-io = { path = "node-graph/libraries/application-io" }
|
||||
core-types = { path = "node-graph/libraries/core-types" }
|
||||
no-std-types = { path = "node-graph/libraries/no-std-types" }
|
||||
@@ -95,7 +97,6 @@ rustc-hash = "2.0"
|
||||
bytemuck = { version = "1.13", features = ["derive", "min_const_generics"] }
|
||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||
serde_json = "1.0"
|
||||
serde_bytes = "0.11"
|
||||
serde-wasm-bindgen = "0.6"
|
||||
reqwest = { version = "0.13", features = ["blocking", "json"] }
|
||||
futures = "0.3"
|
||||
@@ -167,14 +168,17 @@ image = { version = "0.25", default-features = false, features = [
|
||||
"png",
|
||||
"jpeg",
|
||||
"bmp",
|
||||
"gif",
|
||||
] }
|
||||
pretty_assertions = "1.4"
|
||||
fern = { version = "0.7", features = ["colored"] }
|
||||
num_enum = { version = "0.7", default-features = false }
|
||||
num-derive = "0.4"
|
||||
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
|
||||
tsify = { version = "0.5", default-features = false, features = ["js"] }
|
||||
specta = { version = "2.0.0-rc.22", features = [
|
||||
"glam",
|
||||
"derive",
|
||||
# "typescript",
|
||||
] }
|
||||
syn = { version = "2.0", default-features = false, features = [
|
||||
"full",
|
||||
"derive",
|
||||
@@ -209,8 +213,6 @@ cargo-gpu = { git = "https://github.com/Firestar99/cargo-gpu", rev = "3952a22d16
|
||||
qrcodegen = "1.8"
|
||||
lzma-rust2 = { version = "0.16", default-features = false, features = ["std", "encoder", "optimization", "xz"] }
|
||||
scraper = "0.25"
|
||||
linesweeper = "0.3"
|
||||
smallvec = "1.13.2"
|
||||
|
||||
[workspace.lints.rust]
|
||||
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
|
||||
@@ -226,6 +228,7 @@ graphite-proc-macros = { opt-level = 1 }
|
||||
image = { opt-level = 2 }
|
||||
rustc-hash = { opt-level = 3 }
|
||||
serde_derive = { opt-level = 1 }
|
||||
specta-macros = { opt-level = 1 }
|
||||
syn = { opt-level = 1 }
|
||||
node-macro = { opt-level = 2 }
|
||||
|
||||
@@ -233,9 +236,11 @@ node-macro = { opt-level = 2 }
|
||||
lto = "thin"
|
||||
debug = true
|
||||
|
||||
[profile.profiling]
|
||||
inherits = "release"
|
||||
debug = true
|
||||
|
||||
[patch.crates-io]
|
||||
# Force cargo to use only one version of the dpi crate (vendoring breaks without this)
|
||||
dpi = { git = "https://github.com/rust-windowing/winit.git" }
|
||||
download-cef = { git = "https://github.com/timon-schelling/cef-rs.git", branch = "graphite" }
|
||||
vello = { git = "https://github.com/Keavon/vello.git", branch = "0.7.0-fix-images-rendering-blurry" }
|
||||
vello_encoding = { git = "https://github.com/Keavon/vello.git", branch = "0.7.0-fix-images-rendering-blurry" }
|
||||
@@ -39,10 +39,7 @@ db-urls = ["https://github.com/rustsec/advisory-db"]
|
||||
# A list of advisory IDs to ignore. Note that ignored advisories will still
|
||||
# output a note when they are encountered.
|
||||
ignore = [
|
||||
"RUSTSEC-2024-0388", # Unmaintained `derivative`, used directly by graphite-editor and graphite-desktop
|
||||
"RUSTSEC-2024-0436", # Unmaintained `paste`, pulled in by dependencies `metal` and `wgpu-hal`
|
||||
"RUSTSEC-2025-0134", # Unmaintained `rustls-pemfile`, pulled in by build dependency `download-cef`
|
||||
"RUSTSEC-2025-0141", # Unmaintained `bincode`, pulled in by dev dependency `iai-callgrind`
|
||||
"RUSTSEC-2024-0436", # Unmaintained but still fully functional crate `paste`
|
||||
]
|
||||
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
|
||||
# lower than the range specified will be ignored. Note that ignored advisories
|
||||
@@ -186,7 +183,7 @@ allow-git = []
|
||||
|
||||
[sources.allow-org]
|
||||
# 1 or more github.com organizations to allow git sources for
|
||||
github = ["linebender", "Rust-GPU"]
|
||||
github = ["linebender", "Rust-GPU", "specta-rs"]
|
||||
# 1 or more gitlab.com organizations to allow git sources for
|
||||
#gitlab = [""]
|
||||
# 1 or more bitbucket.org organizations to allow git sources for
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![cfg_attr(target_os = "linux", allow(unused))] // TODO: Remove this when bundling for linux is implemented
|
||||
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -29,7 +27,8 @@ pub(crate) fn cef_path() -> PathBuf {
|
||||
}
|
||||
|
||||
pub(crate) fn build_bin(package: &str, bin: Option<&str>) -> Result<PathBuf, Box<dyn Error>> {
|
||||
let mut args = vec!["build", "--package", package, "--profile", profile_name()];
|
||||
let profile = &profile_name();
|
||||
let mut args = vec!["build", "--package", package, "--profile", profile];
|
||||
if let Some(bin) = bin {
|
||||
args.push("--bin");
|
||||
args.push(bin);
|
||||
@@ -46,7 +45,7 @@ pub(crate) fn build_bin(package: &str, bin: Option<&str>) -> Result<PathBuf, Box
|
||||
pub(crate) fn run_command(program: &str, args: &[&str]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let status = Command::new(program).args(args).stdout(Stdio::inherit()).stderr(Stdio::inherit()).status()?;
|
||||
if !status.success() {
|
||||
return Err(format!("Command '{}' with args {:?} failed with status: {}", program, args, status).into());
|
||||
std::process::exit(1);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
use std::error::Error;
|
||||
|
||||
use crate::common::*;
|
||||
|
||||
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
let app_bin = build_bin("graphite-desktop-platform-linux", None)?;
|
||||
|
||||
// TODO: Implement bundling for linux
|
||||
|
||||
// TODO: Consider adding more useful cli
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if let Some(pos) = args.iter().position(|a| a == "open") {
|
||||
let extra_args: Vec<&str> = args[pos + 1..].iter().map(|s| s.as_str()).collect();
|
||||
run_command(&app_bin.to_string_lossy(), &extra_args).expect("failed to open app");
|
||||
if std::env::args().any(|a| a == "open") {
|
||||
run_command(&app_bin.to_string_lossy(), &[]).expect("failed to open app");
|
||||
} else {
|
||||
eprintln!("Binary built and placed at {}", app_bin.to_string_lossy());
|
||||
println!("Binary built and placed at {}", app_bin.to_string_lossy());
|
||||
eprintln!("Bundling for Linux is not yet implemented.");
|
||||
eprintln!("You can still start the app with the `open` subcommand. `cargo run -p graphite-desktop-bundle -- open`");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -22,11 +22,9 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
let app_dir = bundle(&profile_path, &app_bin, &helper_bin);
|
||||
|
||||
// TODO: Consider adding more useful cli
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if let Some(pos) = args.iter().position(|a| a == "open") {
|
||||
let executable = app_dir.join(EXEC_PATH).join(APP_NAME);
|
||||
let extra_args: Vec<&str> = args[pos + 1..].iter().map(|s| s.as_str()).collect();
|
||||
run_command(&executable.to_string_lossy(), &extra_args).expect("failed to open app");
|
||||
if std::env::args().any(|a| a == "open") {
|
||||
let executable_path = app_dir.join(EXEC_PATH).join(APP_NAME);
|
||||
run_command(&executable_path.to_string_lossy(), &[]).expect("failed to open app");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -12,10 +12,9 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
let executable = bundle(&profile_path(), &app_bin);
|
||||
|
||||
// TODO: Consider adding more useful cli
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if let Some(pos) = args.iter().position(|a| a == "open") {
|
||||
let extra_args: Vec<&str> = args[pos + 1..].iter().map(|s| s.as_str()).collect();
|
||||
run_command(&executable.to_string_lossy(), &extra_args).expect("failed to open app")
|
||||
if std::env::args().any(|a| a == "open") {
|
||||
let executable_path = executable.to_string_lossy();
|
||||
run_command(&executable_path, &[]).expect("failed to open app")
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -55,7 +54,6 @@ fn remove_unnecessary_cef_files(app_dir: &Path) -> Result<(), Box<dyn Error>> {
|
||||
fs::remove_file(app_dir.join("bootstrapc.exe"))?;
|
||||
fs::remove_file(app_dir.join("bootstrap.exe"))?;
|
||||
fs::remove_file(app_dir.join("libcef.lib"))?;
|
||||
fs::remove_file(app_dir.join("CREDITS.html"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+2
-11
@@ -21,7 +21,7 @@ use crate::persist::PersistentData;
|
||||
use crate::preferences;
|
||||
use crate::render::{RenderError, RenderState};
|
||||
use crate::window::Window;
|
||||
use crate::wrapper::messages::{DesktopFrontendMessage, DesktopWrapperMessage, InputMessage, MouseKeys, MouseState, Preferences};
|
||||
use crate::wrapper::messages::{DesktopFrontendMessage, DesktopWrapperMessage, InputMessage, MouseKeys, MouseState};
|
||||
use crate::wrapper::{DesktopWrapper, NodeGraphExecutionResult, WgpuContext, serialize_frontend_messages};
|
||||
|
||||
pub(crate) struct App {
|
||||
@@ -46,8 +46,6 @@ pub(crate) struct App {
|
||||
web_communication_initialized: bool,
|
||||
web_communication_startup_buffer: Vec<Vec<u8>>,
|
||||
persistent_data: PersistentData,
|
||||
#[cfg_attr(not(target_os = "macos"), expect(unused))]
|
||||
preferences: Preferences,
|
||||
cli: Cli,
|
||||
startup_time: Option<Instant>,
|
||||
exiting: Arc<AtomicBool>,
|
||||
@@ -65,7 +63,6 @@ impl App {
|
||||
wgpu_context: WgpuContext,
|
||||
app_event_receiver: Receiver<AppEvent>,
|
||||
app_event_scheduler: AppEventScheduler,
|
||||
preferences: Preferences,
|
||||
cli: Cli,
|
||||
) -> Self {
|
||||
let ctrlc_app_event_scheduler = app_event_scheduler.clone();
|
||||
@@ -119,7 +116,6 @@ impl App {
|
||||
web_communication_initialized: false,
|
||||
web_communication_startup_buffer: Vec::new(),
|
||||
persistent_data,
|
||||
preferences,
|
||||
cli,
|
||||
startup_time: None,
|
||||
exiting,
|
||||
@@ -520,12 +516,7 @@ impl ApplicationHandler for App {
|
||||
let window = Window::new(event_loop, self.app_event_scheduler.clone());
|
||||
self.window = Some(window);
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let present_mode = None;
|
||||
#[cfg(target_os = "macos")]
|
||||
let present_mode = if !self.preferences.vsync { Some(wgpu::PresentMode::Immediate) } else { None };
|
||||
|
||||
let render_state = RenderState::new(self.window.as_ref().unwrap(), self.wgpu_context.clone(), present_mode);
|
||||
let render_state = RenderState::new(self.window.as_ref().unwrap(), self.wgpu_context.clone());
|
||||
self.render_state = Some(render_state);
|
||||
|
||||
if let Some(window) = &self.window.as_ref() {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use cef::args::Args;
|
||||
use cef::sys::{CEF_API_VERSION_LAST, cef_log_severity_t};
|
||||
use cef::sys::{CEF_API_VERSION_LAST, cef_log_severity_t, cef_resultcode_t};
|
||||
use cef::{
|
||||
App, BrowserSettings, CefString, Client, DictionaryValue, ImplCommandLine, ImplRequestContext, LogSeverity, RequestContextSettings, SchemeHandlerFactory, Settings, WindowInfo, api_hash,
|
||||
browser_host_create_browser_sync, execute_process,
|
||||
};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use super::CefContext;
|
||||
use super::singlethreaded::SingleThreadedCefContext;
|
||||
@@ -137,7 +138,8 @@ impl<H: CefEventHandler> CefContextBuilder<H> {
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
panic!("Failed to initialize CEF context: {:?}", e);
|
||||
tracing::error!("Failed to initialize CEF context: {:?}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -151,7 +153,10 @@ impl<H: CefEventHandler> CefContextBuilder<H> {
|
||||
let result = cef::initialize(Some(self.args.as_main_args()), Some(&settings), Some(&mut cef_app), std::ptr::null_mut());
|
||||
if result != 1 {
|
||||
let cef_exit_code = cef::get_exit_code() as u32;
|
||||
return Err(InitError::InitializationFailureCode(cef_exit_code));
|
||||
if cef_exit_code == cef_resultcode_t::CEF_RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED as u32 {
|
||||
return Err(InitError::AlreadyRunning);
|
||||
}
|
||||
return Err(InitError::InitializationFailed(cef_exit_code));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -223,16 +228,18 @@ fn create_browser<H: CefEventHandler>(event_handler: H, instance_dir: PathBuf, d
|
||||
pub(crate) enum SetupError {
|
||||
#[error("This is the sub process should exit immediately")]
|
||||
Subprocess,
|
||||
#[error("Subprocess returned non zero exit code: {0}")]
|
||||
#[error("Subprocess returned non zero exit code")]
|
||||
SubprocessFailed(String),
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub(crate) enum InitError {
|
||||
#[error("Initialization failed with code: {0}")]
|
||||
InitializationFailureCode(u32),
|
||||
#[error("Initialization failed")]
|
||||
InitializationFailed(u32),
|
||||
#[error("Browser creation failed")]
|
||||
BrowserCreationFailed,
|
||||
#[error("Request context creation failed")]
|
||||
RequestContextCreationFailed,
|
||||
#[error("Another instance is already running")]
|
||||
AlreadyRunning,
|
||||
}
|
||||
@@ -29,8 +29,9 @@ impl CefContext for SingleThreadedCefContext {
|
||||
host.set_zoom_level(view_info.zoom());
|
||||
host.was_resized();
|
||||
|
||||
// Fix for CEF not updating the view after resize
|
||||
// Fix for CEF not updating the view after resize on windows and mac
|
||||
// TODO: remove once https://github.com/chromiumembedded/cef/issues/3822 is fixed
|
||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||
host.invalidate(cef::PaintElementType::default());
|
||||
}
|
||||
|
||||
|
||||
+21
-14
@@ -5,6 +5,7 @@ use crate::consts::APP_LOCK_FILE_NAME;
|
||||
use crate::event::CreateAppEventSchedulerEventLoopExt;
|
||||
use clap::Parser;
|
||||
use std::io::Write;
|
||||
use std::process::exit;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use winit::event_loop::EventLoop;
|
||||
|
||||
@@ -45,7 +46,8 @@ pub fn start() {
|
||||
.truncate(true)
|
||||
.open(dirs::app_data_dir().join(APP_LOCK_FILE_NAME))
|
||||
else {
|
||||
panic!("Failed to open lock file.")
|
||||
tracing::error!("Failed to open lock file, Exiting.");
|
||||
exit(1);
|
||||
};
|
||||
let mut lock = fd_lock::RwLock::new(lock_file);
|
||||
let lock = match lock.try_write() {
|
||||
@@ -58,12 +60,10 @@ pub fn start() {
|
||||
}
|
||||
Err(_) => {
|
||||
tracing::error!("Another instance is already running, Exiting.");
|
||||
std::process::exit(1);
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let prefs = preferences::read();
|
||||
|
||||
// Must be called before event loop initialization or native window integrations will break
|
||||
App::init();
|
||||
|
||||
@@ -75,7 +75,7 @@ pub fn start() {
|
||||
|
||||
let (cef_view_info_sender, cef_view_info_receiver) = std::sync::mpsc::channel();
|
||||
|
||||
let disable_ui_acceleration = prefs.disable_ui_acceleration || cli.disable_ui_acceleration;
|
||||
let disable_ui_acceleration = preferences::read().disable_ui_acceleration || cli.disable_ui_acceleration;
|
||||
if disable_ui_acceleration {
|
||||
println!("UI acceleration is disabled");
|
||||
}
|
||||
@@ -86,18 +86,25 @@ pub fn start() {
|
||||
tracing::info!("CEF initialized successfully");
|
||||
context
|
||||
}
|
||||
Err(cef::InitError::InitializationFailureCode(code)) => {
|
||||
panic!("CEF initialization failed with code: {code}");
|
||||
Err(cef::InitError::AlreadyRunning) => {
|
||||
tracing::error!("Another instance is already running, Exiting.");
|
||||
exit(1);
|
||||
}
|
||||
Err(cef::InitError::InitializationFailed(code)) => {
|
||||
tracing::error!("Cef initialization failed with code: {code}");
|
||||
exit(1);
|
||||
}
|
||||
Err(cef::InitError::BrowserCreationFailed) => {
|
||||
panic!("Failed to create CEF browser");
|
||||
tracing::error!("Failed to create CEF browser");
|
||||
exit(1);
|
||||
}
|
||||
Err(cef::InitError::RequestContextCreationFailed) => {
|
||||
panic!("Failed to create CEF request context");
|
||||
tracing::error!("Failed to create CEF request context");
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let app = App::new(Box::new(cef_context), cef_view_info_sender, wgpu_context, app_event_receiver, app_event_scheduler, prefs, cli);
|
||||
let app = App::new(Box::new(cef_context), cef_view_info_sender, wgpu_context, app_event_receiver, app_event_scheduler, cli);
|
||||
|
||||
let exit_reason = app.run(event_loop);
|
||||
|
||||
@@ -113,15 +120,15 @@ pub fn start() {
|
||||
drop(lock);
|
||||
|
||||
match exit_reason {
|
||||
#[cfg(target_os = "linux")]
|
||||
app::ExitReason::Restart | app::ExitReason::UiAccelerationFailure => {
|
||||
tracing::info!("Restarting application");
|
||||
tracing::error!("Restarting application");
|
||||
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
|
||||
#[cfg(target_family = "unix")]
|
||||
let _ = std::os::unix::process::CommandExt::exec(&mut command);
|
||||
#[cfg(target_family = "unix")]
|
||||
tracing::error!("Failed to restart application");
|
||||
#[cfg(not(target_family = "unix"))]
|
||||
let _ = command.spawn();
|
||||
tracing::error!("Failed to restart application");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -132,7 +139,7 @@ pub fn start() {
|
||||
// Calling `exit` bypasses rust teardown and lets Windows perform process cleanup.
|
||||
// TODO: Identify and fix the underlying CEF shutdown issue so this workaround can be removed.
|
||||
#[cfg(target_os = "windows")]
|
||||
std::process::exit(0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
pub fn start_helper() {
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
// =============
|
||||
// VERTEX SHADER
|
||||
// =============
|
||||
|
||||
struct VertexOutput {
|
||||
@builtin(position) clip_position: vec4<f32>,
|
||||
@location(0) tex_coords: vec2<f32>,
|
||||
@@ -10,21 +6,19 @@ struct VertexOutput {
|
||||
@vertex
|
||||
fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
|
||||
let pos = array(
|
||||
vec2f(-1.0, -1.0),
|
||||
vec2f(3.0, -1.0),
|
||||
vec2f(-1.0, 3.0),
|
||||
vec2f( -1.0, -1.0),
|
||||
vec2f( 3.0, -1.0),
|
||||
vec2f( -1.0, 3.0),
|
||||
);
|
||||
let xy = pos[vertex_index];
|
||||
out.clip_position = vec4f(xy, 0.0, 1.0);
|
||||
let coords = xy / 2. + 0.5;
|
||||
out.clip_position = vec4f(xy , 0.0, 1.0);
|
||||
let coords = (xy / 2. + 0.5);
|
||||
out.tex_coords = vec2f(coords.x, 1. - coords.y);
|
||||
return out;
|
||||
}
|
||||
|
||||
// ===============
|
||||
// FRAGMENT SHADER
|
||||
// ===============
|
||||
|
||||
struct Constants {
|
||||
viewport_scale: vec2<f32>,
|
||||
@@ -71,8 +65,6 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
|
||||
if (viewport_srgb.a < 0.001) {
|
||||
viewport_srgb = constants.background_color;
|
||||
} else if (viewport_srgb.a < 0.999) {
|
||||
viewport_srgb = blend(viewport_srgb, constants.background_color);
|
||||
}
|
||||
|
||||
if (overlay_srgb.a < 0.001) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::borrow::Cow;
|
||||
use wgpu::PresentMode;
|
||||
|
||||
use crate::window::Window;
|
||||
use crate::wrapper::{TargetTexture, WgpuContext, WgpuExecutor};
|
||||
@@ -12,13 +11,13 @@ pub(crate) struct RenderState {
|
||||
executor: WgpuExecutor,
|
||||
config: wgpu::SurfaceConfiguration,
|
||||
render_pipeline: wgpu::RenderPipeline,
|
||||
transparent_texture: std::sync::Arc<wgpu::Texture>,
|
||||
transparent_texture: wgpu::Texture,
|
||||
sampler: wgpu::Sampler,
|
||||
desired_width: u32,
|
||||
desired_height: u32,
|
||||
viewport_scale: [f32; 2],
|
||||
viewport_offset: [f32; 2],
|
||||
viewport_texture: Option<std::sync::Arc<wgpu::Texture>>,
|
||||
viewport_texture: Option<wgpu::Texture>,
|
||||
overlays_texture: Option<TargetTexture>,
|
||||
ui_texture: Option<wgpu::Texture>,
|
||||
bind_group: Option<wgpu::BindGroup>,
|
||||
@@ -28,7 +27,7 @@ pub(crate) struct RenderState {
|
||||
}
|
||||
|
||||
impl RenderState {
|
||||
pub(crate) fn new(window: &Window, context: WgpuContext, present_mode: Option<PresentMode>) -> Self {
|
||||
pub(crate) fn new(window: &Window, context: WgpuContext) -> Self {
|
||||
let size = window.surface_size();
|
||||
let surface = window.create_surface(context.instance.clone());
|
||||
|
||||
@@ -40,7 +39,10 @@ impl RenderState {
|
||||
format: surface_format,
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
present_mode: present_mode.unwrap_or(surface_caps.present_modes[0]),
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
present_mode: surface_caps.present_modes[0],
|
||||
#[cfg(target_os = "macos")]
|
||||
present_mode: wgpu::PresentMode::Immediate,
|
||||
alpha_mode: surface_caps.alpha_modes[0],
|
||||
view_formats: vec![],
|
||||
desired_maximum_frame_latency: 1,
|
||||
@@ -48,7 +50,7 @@ impl RenderState {
|
||||
|
||||
surface.configure(&context.device, &config);
|
||||
|
||||
let transparent_texture = std::sync::Arc::new(context.device.create_texture(&wgpu::TextureDescriptor {
|
||||
let transparent_texture = context.device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("Transparent Texture"),
|
||||
size: wgpu::Extent3d {
|
||||
width: 1,
|
||||
@@ -61,7 +63,7 @@ impl RenderState {
|
||||
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
|
||||
view_formats: &[],
|
||||
}));
|
||||
});
|
||||
|
||||
// Create shader module
|
||||
let shader = context.device.create_shader_module(wgpu::include_wgsl!("composite_shader.wgsl"));
|
||||
@@ -205,7 +207,7 @@ impl RenderState {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn bind_viewport_texture(&mut self, viewport_texture: std::sync::Arc<wgpu::Texture>) {
|
||||
pub(crate) fn bind_viewport_texture(&mut self, viewport_texture: wgpu::Texture) {
|
||||
self.viewport_texture = Some(viewport_texture);
|
||||
self.update_bindgroup();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ fn menu_items_from_wrapper(entries: Vec<WrapperMenuItem>) -> Vec<MenuItemKind> {
|
||||
}
|
||||
WrapperMenuItem::SubMenu { text: name, items, .. } => {
|
||||
let items = menu_items_from_wrapper(items);
|
||||
let items = items.iter().map(menu_item_kind_to_dyn).collect::<Vec<&dyn IsMenuItem>>();
|
||||
let items = items.iter().map(|item| menu_item_kind_to_dyn(item)).collect::<Vec<&dyn IsMenuItem>>();
|
||||
let submenu = Submenu::with_items(name, true, &items).unwrap();
|
||||
menu_items.push(MenuItemKind::Submenu(submenu));
|
||||
}
|
||||
@@ -106,7 +106,7 @@ fn replace_children<'a, T: Into<MenuContainer<'a>>>(menu: T, new_items: Vec<Menu
|
||||
for item in items.iter() {
|
||||
menu.remove(menu_item_kind_to_dyn(item)).unwrap();
|
||||
}
|
||||
let items = new_items.iter().map(menu_item_kind_to_dyn).collect::<Vec<&dyn IsMenuItem>>();
|
||||
let items = new_items.iter().map(|item| menu_item_kind_to_dyn(item)).collect::<Vec<&dyn IsMenuItem>>();
|
||||
menu.append_items(items.as_ref()).unwrap();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#[cfg(target_os = "macos")]
|
||||
use graphite_editor::messages::layout::utility_types::layout_widget::LayoutTarget;
|
||||
use graphite_editor::messages::prelude::FrontendMessage;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::DesktopWrapperMessageDispatcher;
|
||||
use super::messages::{DesktopFrontendMessage, Document, FileFilter, OpenFileDialogContext, SaveFileDialogContext};
|
||||
@@ -24,21 +25,14 @@ pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageD
|
||||
context: OpenFileDialogContext::Import,
|
||||
});
|
||||
}
|
||||
FrontendMessage::TriggerSaveDocument {
|
||||
document_id,
|
||||
name,
|
||||
path,
|
||||
folder,
|
||||
content,
|
||||
} => {
|
||||
let content = content.into_vec();
|
||||
FrontendMessage::TriggerSaveDocument { document_id, name, path, content } => {
|
||||
if let Some(path) = path {
|
||||
dispatcher.respond(DesktopFrontendMessage::WriteFile { path, content });
|
||||
} else {
|
||||
dispatcher.respond(DesktopFrontendMessage::SaveFileDialog {
|
||||
title: "Save Document".to_string(),
|
||||
default_filename: name,
|
||||
default_folder: folder,
|
||||
default_folder: path.and_then(|p| p.parent().map(PathBuf::from)),
|
||||
filters: vec![FileFilter {
|
||||
name: "Graphite".to_string(),
|
||||
extensions: vec!["graphite".to_string()],
|
||||
@@ -47,12 +41,11 @@ pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageD
|
||||
});
|
||||
}
|
||||
}
|
||||
FrontendMessage::TriggerSaveFile { name, folder, content } => {
|
||||
let content = content.into_vec();
|
||||
FrontendMessage::TriggerSaveFile { name, content } => {
|
||||
dispatcher.respond(DesktopFrontendMessage::SaveFileDialog {
|
||||
title: "Save File".to_string(),
|
||||
default_filename: name,
|
||||
default_folder: folder,
|
||||
default_folder: None,
|
||||
filters: Vec::new(),
|
||||
context: SaveFileDialogContext::File { content },
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ impl DesktopWrapper {
|
||||
}
|
||||
|
||||
pub enum NodeGraphExecutionResult {
|
||||
HasRun(Option<std::sync::Arc<wgpu::Texture>>),
|
||||
HasRun(Option<wgpu::Texture>),
|
||||
NotRun,
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ pub(crate) use graphite_editor::messages::prelude::Message as EditorMessage;
|
||||
|
||||
pub use graphite_editor::messages::input_mapper::utility_types::input_keyboard::{Key, ModifierKeys};
|
||||
pub use graphite_editor::messages::input_mapper::utility_types::input_mouse::{EditorMouseState as MouseState, EditorPosition as Position, MouseKeys};
|
||||
pub use graphite_editor::messages::prelude::DocumentId;
|
||||
pub use graphite_editor::messages::prelude::InputPreprocessorMessage as InputMessage;
|
||||
pub use graphite_editor::messages::prelude::PreferencesMessageHandler as Preferences;
|
||||
|
||||
pub use graphite_editor::messages::prelude::DocumentId;
|
||||
pub use graphite_editor::messages::prelude::PreferencesMessageHandler as Preferences;
|
||||
pub enum DesktopFrontendMessage {
|
||||
ToWeb(Vec<FrontendMessage>),
|
||||
OpenLaunchDocuments,
|
||||
|
||||
@@ -6,7 +6,7 @@ pub(crate) mod menu {
|
||||
use graphite_editor::messages::input_mapper::utility_types::input_keyboard::{Key, LabeledKeyOrMouseMotion, LabeledShortcut};
|
||||
use graphite_editor::messages::input_mapper::utility_types::misc::ActionShortcut;
|
||||
use graphite_editor::messages::layout::LayoutMessage;
|
||||
use graphite_editor::messages::tool::tool_messages::tool_prelude::{Layout, LayoutGroup, LayoutTarget, MenuListEntry, Widget, WidgetId, WidgetRow};
|
||||
use graphite_editor::messages::tool::tool_messages::tool_prelude::{Layout, LayoutGroup, LayoutTarget, MenuListEntry, Widget, WidgetId};
|
||||
|
||||
use crate::messages::{EditorMessage, KeyCode, MenuItem, Modifiers, Shortcut};
|
||||
|
||||
@@ -15,11 +15,11 @@ pub(crate) mod menu {
|
||||
[layout_group] => layout_group,
|
||||
_ => panic!("Menu bar layout is supposed to have exactly one layout group"),
|
||||
};
|
||||
let LayoutGroup::Row(WidgetRow { widgets }) = layout_group else {
|
||||
let LayoutGroup::Row { widgets } = layout_group else {
|
||||
panic!("Menu bar layout group is supposed to be a row");
|
||||
};
|
||||
widgets
|
||||
.iter()
|
||||
.into_iter()
|
||||
.map(|widget| {
|
||||
let text_button = match widget.widget.as_ref() {
|
||||
Widget::TextButton(text_button) => text_button,
|
||||
@@ -79,7 +79,7 @@ pub(crate) mod menu {
|
||||
let enabled = !*disabled;
|
||||
|
||||
if !children.is_empty() {
|
||||
let items = convert_menu_bar_entry_children_to_menu_items(children, root_widget_id, path.clone());
|
||||
let items = convert_menu_bar_entry_children_to_menu_items(&children, root_widget_id, path.clone());
|
||||
return MenuItem::SubMenu { id, text, enabled, items };
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ pub(crate) mod menu {
|
||||
_ => None,
|
||||
};
|
||||
|
||||
match icon.as_deref() {
|
||||
Some("CheckboxChecked") => {
|
||||
match icon.as_str() {
|
||||
"CheckboxChecked" => {
|
||||
return MenuItem::Checkbox {
|
||||
id,
|
||||
text,
|
||||
@@ -98,7 +98,7 @@ pub(crate) mod menu {
|
||||
checked: true,
|
||||
};
|
||||
}
|
||||
Some("CheckboxUnchecked") => {
|
||||
"CheckboxUnchecked" => {
|
||||
return MenuItem::Checkbox {
|
||||
id,
|
||||
text,
|
||||
|
||||
+1
-2
@@ -29,13 +29,12 @@ log = { workspace = true }
|
||||
bitflags = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_bytes = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
kurbo = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
glam = { workspace = true }
|
||||
derivative = { workspace = true }
|
||||
tsify = { workspace = true }
|
||||
specta = { workspace = true }
|
||||
dyn-any = { workspace = true }
|
||||
num_enum = { workspace = true }
|
||||
usvg = { workspace = true }
|
||||
|
||||
@@ -596,7 +596,7 @@ mod test {
|
||||
} = response
|
||||
{
|
||||
if let DiffUpdate::Layout(sub_layout) = &diff[0].new_value {
|
||||
if let LayoutGroup::Row(WidgetRow { widgets }) = &sub_layout.0[0] {
|
||||
if let LayoutGroup::Row { widgets } = &sub_layout.0[0] {
|
||||
if let Widget::TextLabel(TextLabel { value, .. }) = &*widgets[0].widget {
|
||||
print_problem_to_terminal_on_failure(value);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/// Running this test will generate a `types.ts` file at the root of the repo,
|
||||
/// containing every type annotated with `specta::Type`
|
||||
// #[cfg(all(test, feature = "specta-export"))]
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn generate_ts_types() {
|
||||
// TODO: Un-comment this out when we figure out how to reenable the "typescript` Specta feature flag
|
||||
|
||||
// use crate::messages::prelude::FrontendMessage;
|
||||
// use specta::ts::{export_named_datatype, BigIntExportBehavior, ExportConfig};
|
||||
// use specta::{NamedType, TypeMap};
|
||||
// use std::fs::File;
|
||||
// use std::io::Write;
|
||||
|
||||
// let config = ExportConfig::new().bigint(BigIntExportBehavior::Number);
|
||||
|
||||
// let mut type_map = TypeMap::default();
|
||||
|
||||
// let datatype = FrontendMessage::definition_named_data_type(&mut type_map);
|
||||
|
||||
// let mut export = String::new();
|
||||
|
||||
// export += &export_named_datatype(&config, &datatype, &type_map).unwrap();
|
||||
|
||||
// type_map
|
||||
// .iter()
|
||||
// .map(|(_, v)| v)
|
||||
// .flat_map(|v| export_named_datatype(&config, v, &type_map))
|
||||
// .for_each(|e| export += &format!("\n\n{e}"));
|
||||
|
||||
// let mut file = File::create("../types.ts").unwrap();
|
||||
|
||||
// write!(file, "{export}").ok();
|
||||
}
|
||||
@@ -3,6 +3,7 @@ extern crate graphite_proc_macros;
|
||||
// `macro_use` puts these macros into scope for all descendant code files
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
mod generate_ts_types;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
|
||||
@@ -11,46 +11,37 @@ impl MessageHandler<AppWindowMessage, ()> for AppWindowMessageHandler {
|
||||
fn process_message(&mut self, message: AppWindowMessage, responses: &mut std::collections::VecDeque<Message>, _: ()) {
|
||||
match message {
|
||||
AppWindowMessage::PointerLock => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
responses.add(FrontendMessage::WindowPointerLock);
|
||||
}
|
||||
AppWindowMessage::PointerLockMove { x, y } => {
|
||||
responses.add(FrontendMessage::WindowPointerLockMove { position: (x, y) });
|
||||
responses.add(FrontendMessage::WindowPointerLockMove { x, y });
|
||||
}
|
||||
AppWindowMessage::Close => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
responses.add(FrontendMessage::WindowClose);
|
||||
}
|
||||
AppWindowMessage::Minimize => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
responses.add(FrontendMessage::WindowMinimize);
|
||||
}
|
||||
AppWindowMessage::Maximize => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
responses.add(FrontendMessage::WindowMaximize);
|
||||
}
|
||||
AppWindowMessage::Fullscreen => {
|
||||
responses.add(FrontendMessage::WindowFullscreen);
|
||||
}
|
||||
AppWindowMessage::Drag => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
responses.add(FrontendMessage::WindowDrag);
|
||||
}
|
||||
AppWindowMessage::Hide => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
responses.add(FrontendMessage::WindowHide);
|
||||
}
|
||||
AppWindowMessage::HideOthers => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
responses.add(FrontendMessage::WindowHideOthers);
|
||||
}
|
||||
AppWindowMessage::ShowAll => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
responses.add(FrontendMessage::WindowShowAll);
|
||||
}
|
||||
AppWindowMessage::Restart => {
|
||||
responses.add(PortfolioMessage::AutoSaveAllDocuments);
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
responses.add(FrontendMessage::WindowRestart);
|
||||
}
|
||||
}
|
||||
@@ -66,8 +57,7 @@ impl MessageHandler<AppWindowMessage, ()> for AppWindowMessageHandler {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Default, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Default, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum AppWindowPlatform {
|
||||
#[default]
|
||||
Web,
|
||||
|
||||
@@ -37,7 +37,5 @@ pub enum DialogMessage {
|
||||
},
|
||||
RequestNewDocumentDialog,
|
||||
RequestPreferencesDialog,
|
||||
RequestConfirmRestartDialog {
|
||||
preferences_requiring_restart: Vec<String>,
|
||||
},
|
||||
RequestConfirmRestartDialog,
|
||||
}
|
||||
@@ -136,9 +136,11 @@ impl MessageHandler<DialogMessage, DialogMessageContext<'_>> for DialogMessageHa
|
||||
self.on_dismiss = Some(PreferencesDialogMessage::Confirm.into());
|
||||
self.preferences_dialog.send_dialog_to_frontend(responses, preferences);
|
||||
}
|
||||
DialogMessage::RequestConfirmRestartDialog { preferences_requiring_restart } => {
|
||||
DialogMessage::RequestConfirmRestartDialog => {
|
||||
self.on_dismiss = Some(DialogMessage::Close.into());
|
||||
let dialog = ConfirmRestartDialog { preferences_requiring_restart };
|
||||
let dialog = ConfirmRestartDialog {
|
||||
changed_settings: vec!["Disable UI Acceleration".into()],
|
||||
};
|
||||
dialog.send_dialog_to_frontend(responses);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ impl DialogLayoutHolder for ExportDialogMessageHandler {
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,6 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
||||
.unit("")
|
||||
.min(0.)
|
||||
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
|
||||
.increment_step(0.5)
|
||||
.disabled(self.file_type == FileType::Svg)
|
||||
.on_update(|number_input: &NumberInput| ExportDialogMessage::ScaleFactor { factor: number_input.value.unwrap() }.into())
|
||||
.min_width(200)
|
||||
@@ -171,10 +170,10 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
||||
];
|
||||
|
||||
Layout(vec![
|
||||
LayoutGroup::row(export_type),
|
||||
LayoutGroup::row(resolution),
|
||||
LayoutGroup::row(export_area),
|
||||
LayoutGroup::row(transparent_background),
|
||||
LayoutGroup::Row { widgets: export_type },
|
||||
LayoutGroup::Row { widgets: resolution },
|
||||
LayoutGroup::Row { widgets: export_area },
|
||||
LayoutGroup::Row { widgets: transparent_background },
|
||||
])
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -71,7 +71,7 @@ impl DialogLayoutHolder for NewDocumentDialogMessageHandler {
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,6 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
Layout(vec![LayoutGroup::row(name), LayoutGroup::row(infinite), LayoutGroup::row(scale)])
|
||||
Layout(vec![LayoutGroup::Row { widgets: name }, LayoutGroup::Row { widgets: infinite }, LayoutGroup::Row { widgets: scale }])
|
||||
}
|
||||
}
|
||||
+4
-40
@@ -28,10 +28,9 @@ impl MessageHandler<PreferencesDialogMessage, PreferencesDialogMessageContext<'_
|
||||
}
|
||||
PreferencesDialogMessage::Confirm => {
|
||||
if let Some(unmodified_preferences) = &self.unmodified_preferences
|
||||
&& let preferences_requiring_restart = unmodified_preferences.preferences_requiring_restart(preferences)
|
||||
&& !preferences_requiring_restart.is_empty()
|
||||
&& unmodified_preferences.needs_restart(preferences)
|
||||
{
|
||||
responses.add(DialogMessage::RequestConfirmRestartDialog { preferences_requiring_restart });
|
||||
responses.add(DialogMessage::RequestConfirmRestartDialog);
|
||||
} else {
|
||||
responses.add(DialogMessage::Close);
|
||||
}
|
||||
@@ -388,44 +387,9 @@ impl PreferencesDialogMessageHandler {
|
||||
|
||||
rows.push(ui_acceleration);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let vsync_description = "
|
||||
Render frames with vertical synchronization (v-sync) to prevent visual tearing within Graphite and the operating system compositor. This introduces increased input latency which is more noticeable on lower refresh rate displays. Future versions of Graphite will aim to reduce the macOS-specific latency without tearing artifacts.\n\
|
||||
\n\
|
||||
The application will restart for this change to take effect.\n\
|
||||
\n\
|
||||
*Default: Off.*
|
||||
"
|
||||
.trim();
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let vsync_checked = preferences.vsync;
|
||||
|
||||
let vsync = vec![
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(vsync_checked)
|
||||
.tooltip_label("Enable V-Sync")
|
||||
.tooltip_description(vsync_description)
|
||||
.on_update(|checkbox_input: &CheckboxInput| Message::Batched {
|
||||
messages: Box::new([PreferencesDialogMessage::MayRequireRestart.into(), PreferencesMessage::VSync { vsync: checkbox_input.checked }.into()]),
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Enable V-Sync")
|
||||
.tooltip_label("Enable V-Sync")
|
||||
.tooltip_description(vsync_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
rows.push(vsync);
|
||||
}
|
||||
}
|
||||
|
||||
Layout(rows.into_iter().map(LayoutGroup::row).collect())
|
||||
Layout(rows.into_iter().map(|r| LayoutGroup::Row { widgets: r }).collect())
|
||||
}
|
||||
|
||||
pub fn send_layout(&self, responses: &mut VecDeque<Message>, layout_target: LayoutTarget, preferences: &PreferencesMessageHandler) {
|
||||
@@ -452,7 +416,7 @@ impl PreferencesDialogMessageHandler {
|
||||
TextButton::new("Reset to Defaults").on_update(|_| PreferencesMessage::ResetToDefaults.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
|
||||
fn send_layout_buttons(&self, responses: &mut VecDeque<Message>, layout_target: LayoutTarget) {
|
||||
|
||||
@@ -15,7 +15,7 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
|
||||
fn layout_column_2(&self) -> Layout {
|
||||
@@ -29,7 +29,7 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
||||
.into_iter()
|
||||
.map(|(icon, label, url)| {
|
||||
TextButton::new(label)
|
||||
.icon(icon)
|
||||
.icon(Some(icon.into()))
|
||||
.flush(true)
|
||||
.on_update(|_| FrontendMessage::TriggerVisitLink { url: url.into() }.into())
|
||||
.widget_instance()
|
||||
@@ -40,7 +40,7 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
||||
let localized_commit_year = self.localized_commit_year.clone();
|
||||
widgets.push(
|
||||
TextButton::new("Licenses")
|
||||
.icon("License")
|
||||
.icon(Some("License".into()))
|
||||
.flush(true)
|
||||
.on_update(move |_| {
|
||||
DialogMessage::RequestLicensesDialogWithLocalizedCommitDate {
|
||||
@@ -51,16 +51,22 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
||||
.widget_instance(),
|
||||
);
|
||||
|
||||
Layout(vec![LayoutGroup::column(widgets)])
|
||||
Layout(vec![LayoutGroup::Column { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutHolder for AboutGraphiteDialog {
|
||||
fn layout(&self) -> Layout {
|
||||
Layout(vec![
|
||||
LayoutGroup::row(vec![TextLabel::new("About this release").bold(true).widget_instance()]),
|
||||
LayoutGroup::row(vec![TextLabel::new(commit_info_localized(&self.localized_commit_date)).multiline(true).widget_instance()]),
|
||||
LayoutGroup::row(vec![TextLabel::new(format!("Copyright © {} Graphite contributors", self.localized_commit_year)).widget_instance()]),
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("About this release").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(commit_info_localized(&self.localized_commit_date)).multiline(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(format!("Copyright © {} Graphite contributors", self.localized_commit_year)).widget_instance()],
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ impl DialogLayoutHolder for CloseAllDocumentsDialog {
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,12 @@ impl LayoutHolder for CloseAllDocumentsDialog {
|
||||
let unsaved_list = "• ".to_string() + &self.unsaved_document_names.join("\n• ");
|
||||
|
||||
Layout(vec![
|
||||
LayoutGroup::row(vec![TextLabel::new("Save documents before closing them?").bold(true).multiline(true).widget_instance()]),
|
||||
LayoutGroup::row(vec![TextLabel::new(format!("Documents with unsaved changes:\n{unsaved_list}")).multiline(true).widget_instance()]),
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Save documents before closing them?").bold(true).multiline(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(format!("Documents with unsaved changes:\n{unsaved_list}")).multiline(true).widget_instance()],
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ impl DialogLayoutHolder for CloseDocumentDialog {
|
||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,12 @@ impl LayoutHolder for CloseDocumentDialog {
|
||||
let break_lines = if self.document_name.len() > max_one_line_length { '\n' } else { ' ' };
|
||||
|
||||
Layout(vec![
|
||||
LayoutGroup::row(vec![TextLabel::new("Save document before closing it?").bold(true).widget_instance()]),
|
||||
LayoutGroup::row(vec![TextLabel::new(format!("\"{name}{ellipsis}\"{break_lines}has unsaved changes")).multiline(true).widget_instance()]),
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Save document before closing it?").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(format!("\"{name}{ellipsis}\"{break_lines}has unsaved changes")).multiline(true).widget_instance()],
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ use crate::messages::prelude::*;
|
||||
|
||||
/// A dialog for confirming the restart of the application when changing a preference that requires a restart to take effect.
|
||||
pub struct ConfirmRestartDialog {
|
||||
pub preferences_requiring_restart: Vec<String>,
|
||||
pub changed_settings: Vec<String>,
|
||||
}
|
||||
|
||||
impl DialogLayoutHolder for ConfirmRestartDialog {
|
||||
@@ -24,32 +24,36 @@ impl DialogLayoutHolder for ConfirmRestartDialog {
|
||||
TextButton::new("Later").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
||||
];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutHolder for ConfirmRestartDialog {
|
||||
fn layout(&self) -> Layout {
|
||||
let changed_settings = "• ".to_string() + &self.preferences_requiring_restart.join("\n• ");
|
||||
let changed_settings = "• ".to_string() + &self.changed_settings.join("\n• ");
|
||||
|
||||
Layout(vec![
|
||||
LayoutGroup::row(vec![TextLabel::new("Restart to apply changes?").bold(true).multiline(true).widget_instance()]),
|
||||
LayoutGroup::row(vec![
|
||||
TextLabel::new(
|
||||
format!(
|
||||
"
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Restart to apply changes?").bold(true).multiline(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new(
|
||||
format!(
|
||||
"
|
||||
Settings that only take effect on next launch:\n\
|
||||
{changed_settings}\n\
|
||||
\n\
|
||||
This only takes a few seconds. Open documents,\n\
|
||||
even unsaved ones, will be automatically restored.
|
||||
"
|
||||
)
|
||||
.trim(),
|
||||
)
|
||||
.trim(),
|
||||
)
|
||||
.multiline(true)
|
||||
.widget_instance(),
|
||||
]),
|
||||
.multiline(true)
|
||||
.widget_instance(),
|
||||
],
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ impl DialogLayoutHolder for DemoArtworkDialog {
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("Close").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ impl LayoutHolder for DemoArtworkDialog {
|
||||
|
||||
let images = chunk
|
||||
.iter()
|
||||
.map(|(name, thumbnail, filename)| ImageButton::new(*thumbnail).width("256px").on_update(|_| make_dialog(name, filename)).widget_instance())
|
||||
.map(|(name, thumbnail, filename)| ImageButton::new(*thumbnail).width(Some("256px".into())).on_update(|_| make_dialog(name, filename)).widget_instance())
|
||||
.collect();
|
||||
|
||||
let buttons = chunk
|
||||
@@ -54,7 +54,7 @@ impl LayoutHolder for DemoArtworkDialog {
|
||||
.map(|(name, _, filename)| TextButton::new(*name).min_width(256).flush(true).on_update(|_| make_dialog(name, filename)).widget_instance())
|
||||
.collect();
|
||||
|
||||
vec![LayoutGroup::row(images), LayoutGroup::row(buttons), LayoutGroup::row(vec![])]
|
||||
vec![LayoutGroup::Row { widgets: images }, LayoutGroup::Row { widgets: buttons }, LayoutGroup::Row { widgets: vec![] }]
|
||||
})
|
||||
.collect();
|
||||
let _ = rows_of_images_with_buttons.pop();
|
||||
|
||||
@@ -14,15 +14,19 @@ impl DialogLayoutHolder for ErrorDialog {
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutHolder for ErrorDialog {
|
||||
fn layout(&self) -> Layout {
|
||||
Layout(vec![
|
||||
LayoutGroup::row(vec![TextLabel::new(&self.title).bold(true).widget_instance()]),
|
||||
LayoutGroup::row(vec![TextLabel::new(&self.description).multiline(true).widget_instance()]),
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(&self.title).bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(&self.description).multiline(true).widget_instance()],
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ impl DialogLayoutHolder for LicensesDialog {
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
|
||||
fn layout_column_2(&self) -> Layout {
|
||||
@@ -34,10 +34,10 @@ impl DialogLayoutHolder for LicensesDialog {
|
||||
];
|
||||
let widgets = button_definitions
|
||||
.iter()
|
||||
.map(|&(icon, label, message_factory)| TextButton::new(label).icon(icon).flush(true).on_update(move |_| message_factory()).widget_instance())
|
||||
.map(|&(icon, label, message_factory)| TextButton::new(label).icon(Some((icon).into())).flush(true).on_update(move |_| message_factory()).widget_instance())
|
||||
.collect();
|
||||
|
||||
Layout(vec![LayoutGroup::column(widgets)])
|
||||
Layout(vec![LayoutGroup::Column { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,12 @@ impl LayoutHolder for LicensesDialog {
|
||||
let description = description.trim();
|
||||
|
||||
Layout(vec![
|
||||
LayoutGroup::row(vec![TextLabel::new("Graphite is free, open source software").bold(true).widget_instance()]),
|
||||
LayoutGroup::row(vec![TextLabel::new(description).multiline(true).widget_instance()]),
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Graphite is free, open source software").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(description).multiline(true).widget_instance()],
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ impl DialogLayoutHolder for LicensesThirdPartyDialog {
|
||||
fn layout_buttons(&self) -> Layout {
|
||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
||||
|
||||
Layout(vec![LayoutGroup::row(widgets)])
|
||||
Layout(vec![LayoutGroup::Row { widgets }])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,14 @@ impl LayoutHolder for LicensesThirdPartyDialog {
|
||||
// Two characters (one before, one after) the sequence of underscore characters, plus one additional column to provide a space between the text and the scrollbar
|
||||
let non_wrapping_column_width = license_text.split('\n').map(|line| line.chars().filter(|&c| c == '_').count() as u32).max().unwrap_or(0) + 2 + 1;
|
||||
|
||||
Layout(vec![LayoutGroup::row(vec![
|
||||
TextLabel::new(license_text)
|
||||
.monospace(true)
|
||||
.multiline(true)
|
||||
.min_width_characters(non_wrapping_column_width)
|
||||
.widget_instance(),
|
||||
])])
|
||||
Layout(vec![LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new(license_text)
|
||||
.monospace(true)
|
||||
.multiline(true)
|
||||
.min_width_characters(non_wrapping_column_width)
|
||||
.widget_instance(),
|
||||
],
|
||||
}])
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
use super::IconName;
|
||||
use super::utility_types::{DocumentDetails, MouseCursorIcon, OpenDocument};
|
||||
use crate::messages::app_window::app_window_message_handler::AppWindowPlatform;
|
||||
use crate::messages::frontend::utility_types::EyedropperPreviewImage;
|
||||
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::node_graph::utility_types::{
|
||||
BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendGraphInput, FrontendGraphOutput, FrontendNode, FrontendNodeType, NodeGraphErrorDiagnostic,
|
||||
BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendGraphInput, FrontendGraphOutput, FrontendNode, FrontendNodeType, NodeGraphErrorDiagnostic, Transform,
|
||||
};
|
||||
use crate::messages::portfolio::document::utility_types::nodes::{LayerPanelEntry, LayerStructureEntry};
|
||||
use crate::messages::portfolio::document::utility_types::wires::{WirePath, WirePathUpdate};
|
||||
use crate::messages::prelude::*;
|
||||
use crate::messages::tool::tool_messages::eyedropper_tool::PrimarySecondary;
|
||||
use glam::IVec2;
|
||||
use graph_craft::document::NodeId;
|
||||
use graphene_std::raster::Image;
|
||||
use graphene_std::raster::color::Color;
|
||||
@@ -21,14 +20,13 @@ use std::path::PathBuf;
|
||||
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
||||
|
||||
#[impl_message(Message, Frontend)]
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(derivative::Derivative, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(derivative::Derivative, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub enum FrontendMessage {
|
||||
// Display prefix: make the frontend show something, like a dialog
|
||||
DisplayDialog {
|
||||
title: String,
|
||||
icon: IconName,
|
||||
icon: String,
|
||||
},
|
||||
DialogClose,
|
||||
DisplayDialogPanic {
|
||||
@@ -43,7 +41,7 @@ pub enum FrontendMessage {
|
||||
font_size: f64,
|
||||
color: String,
|
||||
#[serde(rename = "fontData")]
|
||||
font_data: serde_bytes::ByteBuf,
|
||||
font_data: Vec<u8>,
|
||||
transform: [f64; 6],
|
||||
#[serde(rename = "maxWidth")]
|
||||
max_width: Option<f64>,
|
||||
@@ -53,7 +51,7 @@ pub enum FrontendMessage {
|
||||
},
|
||||
DisplayEditableTextboxUpdateFontData {
|
||||
#[serde(rename = "fontData")]
|
||||
font_data: serde_bytes::ByteBuf,
|
||||
font_data: Vec<u8>,
|
||||
},
|
||||
DisplayEditableTextboxTransform {
|
||||
transform: [f64; 6],
|
||||
@@ -89,13 +87,11 @@ pub enum FrontendMessage {
|
||||
document_id: DocumentId,
|
||||
name: String,
|
||||
path: Option<PathBuf>,
|
||||
folder: Option<PathBuf>,
|
||||
content: serde_bytes::ByteBuf,
|
||||
content: Vec<u8>,
|
||||
},
|
||||
TriggerSaveFile {
|
||||
name: String,
|
||||
folder: Option<PathBuf>,
|
||||
content: serde_bytes::ByteBuf,
|
||||
content: Vec<u8>,
|
||||
},
|
||||
TriggerExportImage {
|
||||
svg: String,
|
||||
@@ -129,7 +125,6 @@ pub enum FrontendMessage {
|
||||
TriggerOpen,
|
||||
TriggerImport,
|
||||
TriggerSavePreferences {
|
||||
#[tsify(type = "unknown")]
|
||||
preferences: PreferencesMessageHandler,
|
||||
},
|
||||
TriggerSaveActiveDocument {
|
||||
@@ -157,8 +152,9 @@ pub enum FrontendMessage {
|
||||
document_id: DocumentId,
|
||||
},
|
||||
UpdateGradientStopColorPickerPosition {
|
||||
color: Color, // TODO: Color (without `none`) -> Color (with `none`)
|
||||
position: (f64, f64),
|
||||
color: Color,
|
||||
x: f64,
|
||||
y: f64,
|
||||
},
|
||||
UpdateImportsExports {
|
||||
/// If the primary import is not visible, then it is None.
|
||||
@@ -167,10 +163,10 @@ pub enum FrontendMessage {
|
||||
exports: Vec<Option<FrontendGraphInput>>,
|
||||
/// The primary import location.
|
||||
#[serde(rename = "importPosition")]
|
||||
import_position: (i32, i32),
|
||||
import_position: IVec2,
|
||||
/// The primary export location.
|
||||
#[serde(rename = "exportPosition")]
|
||||
export_position: (i32, i32),
|
||||
export_position: IVec2,
|
||||
/// The document network does not have an add import or export button.
|
||||
#[serde(rename = "addImportExport")]
|
||||
add_import_export: bool,
|
||||
@@ -206,7 +202,7 @@ pub enum FrontendMessage {
|
||||
UpdateLayout {
|
||||
#[serde(rename = "layoutTarget")]
|
||||
layout_target: LayoutTarget,
|
||||
diff: Vec<WidgetDiff>, // TODO: Align this with what's generated
|
||||
diff: Vec<WidgetDiff>,
|
||||
},
|
||||
UpdateImportReorderIndex {
|
||||
#[serde(rename = "importIndex")]
|
||||
@@ -257,7 +253,7 @@ pub enum FrontendMessage {
|
||||
#[serde(rename = "secondaryColor")]
|
||||
secondary_color: String,
|
||||
#[serde(rename = "setColorChoice")]
|
||||
set_color_choice: Option<PrimarySecondary>,
|
||||
set_color_choice: Option<String>,
|
||||
},
|
||||
UpdateGraphFadeArtwork {
|
||||
percentage: f64,
|
||||
@@ -282,8 +278,7 @@ pub enum FrontendMessage {
|
||||
selected: Vec<NodeId>,
|
||||
},
|
||||
UpdateNodeGraphTransform {
|
||||
translation: (f64, f64),
|
||||
scale: f64,
|
||||
transform: Transform,
|
||||
},
|
||||
UpdateNodeThumbnail {
|
||||
id: NodeId,
|
||||
@@ -309,7 +304,6 @@ pub enum FrontendMessage {
|
||||
UpdateViewportHolePunch {
|
||||
active: bool,
|
||||
},
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
UpdateViewportPhysicalBounds {
|
||||
x: f64,
|
||||
y: f64,
|
||||
@@ -328,26 +322,18 @@ pub enum FrontendMessage {
|
||||
},
|
||||
|
||||
// Window prefix: cause the application window to do something
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
WindowPointerLock,
|
||||
WindowPointerLockMove {
|
||||
position: (f64, f64),
|
||||
x: f64,
|
||||
y: f64,
|
||||
},
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
WindowClose,
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
WindowMinimize,
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
WindowMaximize,
|
||||
WindowFullscreen,
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
WindowDrag,
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
WindowHide,
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
WindowHideOthers,
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
WindowShowAll,
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
WindowRestart,
|
||||
}
|
||||
@@ -4,7 +4,3 @@ pub mod utility_types;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use frontend_message::{FrontendMessage, FrontendMessageDiscriminant};
|
||||
|
||||
// TODO: Make this an enum with the actual icon names, somehow derived from or tied to the frontend icon set.
|
||||
// TODO: Then remove `#[widget_builder(string)]` from all icon fields.
|
||||
pub type IconName = String;
|
||||
@@ -3,15 +3,13 @@ use std::path::PathBuf;
|
||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct OpenDocument {
|
||||
pub id: DocumentId,
|
||||
pub details: DocumentDetails,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct DocumentDetails {
|
||||
pub name: String,
|
||||
pub path: Option<PathBuf>,
|
||||
@@ -21,8 +19,7 @@ pub struct DocumentDetails {
|
||||
pub is_auto_saved: bool,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum MouseCursorIcon {
|
||||
#[default]
|
||||
Default,
|
||||
@@ -40,8 +37,7 @@ pub enum MouseCursorIcon {
|
||||
Rotate,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum FileType {
|
||||
#[default]
|
||||
Png,
|
||||
@@ -59,8 +55,7 @@ impl FileType {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum ExportBounds {
|
||||
#[default]
|
||||
AllArtwork,
|
||||
@@ -68,10 +63,9 @@ pub enum ExportBounds {
|
||||
Artboard(LayerNodeIdentifier),
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct EyedropperPreviewImage {
|
||||
pub data: serde_bytes::ByteBuf,
|
||||
pub data: Vec<u8>,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
}
|
||||
@@ -67,8 +67,7 @@ bitflags! {
|
||||
// (although we ignore the shift key, so the user doesn't have to press `Ctrl Shift +` on a US keyboard), even if the keyboard layout
|
||||
// is for a different locale where the `+` key is somewhere entirely different, shifted or not. This would then also work for numpad `+`.
|
||||
#[impl_message(Message, InputMapperMessage, KeyDown)]
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, num_enum::TryFromPrimitive)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type, num_enum::TryFromPrimitive)]
|
||||
#[repr(u8)]
|
||||
pub enum Key {
|
||||
// Writing system keys
|
||||
@@ -380,8 +379,7 @@ impl fmt::Display for KeysGroup {
|
||||
// LabeledKey
|
||||
// ==========
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct LabeledKey {
|
||||
key: Key,
|
||||
label: String,
|
||||
@@ -397,8 +395,7 @@ impl LabeledKey {
|
||||
// MouseMotion
|
||||
// ===========
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum MouseMotion {
|
||||
None,
|
||||
Lmb,
|
||||
@@ -418,8 +415,7 @@ pub enum MouseMotion {
|
||||
// LabeledKeyOrMouseMotion
|
||||
// =======================
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
#[serde(untagged)]
|
||||
pub enum LabeledKeyOrMouseMotion {
|
||||
Key(LabeledKey),
|
||||
@@ -441,8 +437,7 @@ impl From<Key> for LabeledKeyOrMouseMotion {
|
||||
// LabeledShortcut
|
||||
// ===============
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct LabeledShortcut(pub Vec<LabeledKeyOrMouseMotion>);
|
||||
|
||||
impl From<KeysGroup> for LabeledShortcut {
|
||||
|
||||
@@ -110,8 +110,7 @@ bitflags! {
|
||||
}
|
||||
|
||||
#[impl_message(Message, InputMapperMessage, DoubleClick)]
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, num_enum::TryFromPrimitive)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type, num_enum::TryFromPrimitive)]
|
||||
#[repr(u8)]
|
||||
pub enum MouseButton {
|
||||
Left,
|
||||
|
||||
@@ -106,10 +106,8 @@ pub struct MappingEntry {
|
||||
pub disabled: bool,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum ActionShortcut {
|
||||
#[serde(skip)]
|
||||
Action(MessageDiscriminant),
|
||||
#[serde(rename = "shortcut")]
|
||||
Shortcut(LabeledShortcut),
|
||||
|
||||
@@ -8,7 +8,6 @@ pub enum LayoutMessage {
|
||||
layout_target: LayoutTarget,
|
||||
widget_id: WidgetId,
|
||||
},
|
||||
ResendAllLayouts,
|
||||
SendLayout {
|
||||
layout: Layout,
|
||||
layout_target: LayoutTarget,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use crate::messages::input_mapper::utility_types::input_keyboard::KeysGroup;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
use graphene_std::vector::style::FillChoice;
|
||||
use graphene_std::raster::color::Color;
|
||||
use graphene_std::vector::style::{FillChoice, GradientStop, GradientStops};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -33,20 +34,6 @@ impl MessageHandler<LayoutMessage, LayoutMessageContext<'_>> for LayoutMessageHa
|
||||
// Resend that diff
|
||||
self.send_diff(vec![diff], layout_target, responses, action_input_mapping);
|
||||
}
|
||||
LayoutMessage::ResendAllLayouts => {
|
||||
// Collect non-empty layouts and their indices, then clear the stored copies so diffs compute as full re-sends
|
||||
let layouts_to_resend: Vec<_> = self
|
||||
.layouts
|
||||
.iter_mut()
|
||||
.enumerate()
|
||||
.filter(|(_, layout)| !layout.0.is_empty())
|
||||
.map(|(i, layout)| (LayoutTarget::from(i as u8), std::mem::take(layout)))
|
||||
.collect();
|
||||
|
||||
for (layout_target, layout) in layouts_to_resend {
|
||||
self.diff_and_send_layout_to_frontend(layout_target, layout, responses, action_input_mapping);
|
||||
}
|
||||
}
|
||||
LayoutMessage::SendLayout { layout, layout_target } => {
|
||||
self.diff_and_send_layout_to_frontend(layout_target, layout, responses, action_input_mapping);
|
||||
}
|
||||
@@ -76,7 +63,7 @@ impl LayoutMessageHandler {
|
||||
while let Some((mut widget_path, layout_group)) = stack.pop() {
|
||||
match layout_group {
|
||||
// Check if any of the widgets in the current column or row have the correct id
|
||||
LayoutGroup::Column(WidgetColumn { widgets }) | LayoutGroup::Row(WidgetRow { widgets }) => {
|
||||
LayoutGroup::Column { widgets } | LayoutGroup::Row { widgets } => {
|
||||
for (index, widget) in widgets.iter().enumerate() {
|
||||
// Return if this is the correct ID
|
||||
if widget.widget_id == widget_id {
|
||||
@@ -97,10 +84,10 @@ impl LayoutMessageHandler {
|
||||
}
|
||||
}
|
||||
// A section contains more LayoutGroups which we add to the stack.
|
||||
LayoutGroup::Section(WidgetSection { layout, .. }) => {
|
||||
LayoutGroup::Section { layout, .. } => {
|
||||
stack.extend(layout.0.iter().enumerate().map(|(index, val)| ([widget_path.as_slice(), &[index]].concat(), val)));
|
||||
}
|
||||
LayoutGroup::Table(WidgetTable { rows, .. }) => {
|
||||
LayoutGroup::Table { rows, .. } => {
|
||||
for (row_index, row) in rows.iter().enumerate() {
|
||||
for (cell_index, cell) in row.iter().enumerate() {
|
||||
// Return if this is the correct ID
|
||||
@@ -171,12 +158,60 @@ impl LayoutMessageHandler {
|
||||
let callback_message = match action {
|
||||
WidgetValueAction::Commit => (color_button.on_commit.callback)(&()),
|
||||
WidgetValueAction::Update => {
|
||||
let Ok(fill_choice) = serde_json::from_value::<FillChoice>(value) else {
|
||||
warn!("ColorInput update was not able to be parsed as FillChoice: {color_button:?}");
|
||||
return;
|
||||
// Decodes the colors in gamma, not linear
|
||||
let decode_color = |color: &serde_json::map::Map<String, serde_json::value::Value>| -> Option<Color> {
|
||||
let red = color.get("red").and_then(|x| x.as_f64()).map(|x| x as f32);
|
||||
let green = color.get("green").and_then(|x| x.as_f64()).map(|x| x as f32);
|
||||
let blue = color.get("blue").and_then(|x| x.as_f64()).map(|x| x as f32);
|
||||
let alpha = color.get("alpha").and_then(|x| x.as_f64()).map(|x| x as f32);
|
||||
|
||||
if let (Some(red), Some(green), Some(blue), Some(alpha)) = (red, green, blue, alpha)
|
||||
&& let Some(color) = Color::from_rgbaf32(red, green, blue, alpha)
|
||||
{
|
||||
return Some(color);
|
||||
}
|
||||
None
|
||||
};
|
||||
color_button.value = fill_choice;
|
||||
(color_button.on_update.callback)(color_button)
|
||||
|
||||
(|| {
|
||||
let Some(update_value) = value.as_object() else {
|
||||
warn!("ColorInput update was not of type: object");
|
||||
return Message::NoOp;
|
||||
};
|
||||
|
||||
// None
|
||||
let is_none = update_value.get("none").and_then(|x| x.as_bool());
|
||||
if is_none == Some(true) {
|
||||
color_button.value = FillChoice::None;
|
||||
return (color_button.on_update.callback)(color_button);
|
||||
}
|
||||
|
||||
// Solid
|
||||
if let Some(color) = decode_color(update_value) {
|
||||
color_button.value = FillChoice::Solid(color);
|
||||
return (color_button.on_update.callback)(color_button);
|
||||
}
|
||||
|
||||
// Gradient
|
||||
let positions = update_value.get("position").and_then(|x| x.as_array());
|
||||
let midpoints = update_value.get("midpoint").and_then(|x| x.as_array());
|
||||
let colors = update_value.get("color").and_then(|x| x.as_array());
|
||||
|
||||
if let (Some(positions), Some(midpoints), Some(colors)) = (positions, midpoints, colors) {
|
||||
let gradient_stops = positions.iter().zip(midpoints.iter()).zip(colors.iter()).filter_map(|((pos, mid), col)| {
|
||||
let position = pos.as_f64()?;
|
||||
let midpoint = mid.as_f64()?;
|
||||
let color = col.as_object().and_then(decode_color)?;
|
||||
Some(GradientStop { position, midpoint, color })
|
||||
});
|
||||
|
||||
color_button.value = FillChoice::Gradient(GradientStops::new(gradient_stops));
|
||||
return (color_button.on_update.callback)(color_button);
|
||||
}
|
||||
|
||||
warn!("ColorInput update was not able to be parsed with color data: {color_button:?}");
|
||||
Message::NoOp
|
||||
})()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ use std::hash::{Hash, Hasher};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[repr(transparent)]
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct WidgetId(pub u64);
|
||||
|
||||
impl core::fmt::Display for WidgetId {
|
||||
@@ -20,30 +19,9 @@ impl core::fmt::Display for WidgetId {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! define_layout_target {
|
||||
($($(#[$attr:meta])* $variant:ident),* $(,)?) => {
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Eq, Copy, serde::Serialize, serde::Deserialize)]
|
||||
#[repr(u8)]
|
||||
pub enum LayoutTarget {
|
||||
$($(#[$attr])* $variant,)*
|
||||
// KEEP THIS ENUM LAST
|
||||
// This is a marker that is used to define an array that is used to hold widgets
|
||||
#[serde(skip)]
|
||||
_LayoutTargetLength,
|
||||
}
|
||||
|
||||
impl From<u8> for LayoutTarget {
|
||||
fn from(value: u8) -> Self {
|
||||
match value {
|
||||
$(x if x == Self::$variant as u8 => Self::$variant,)*
|
||||
_ => panic!("Invalid LayoutTarget discriminant: {value}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
define_layout_target!(
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Eq, Copy, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
#[repr(u8)]
|
||||
pub enum LayoutTarget {
|
||||
/// The spreadsheet panel allows for the visualisation of data in the graph.
|
||||
DataPanel,
|
||||
/// Contains the action buttons at the bottom of the dialog. Must be shown with the `FrontendMessage::DisplayDialog` message.
|
||||
@@ -78,7 +56,11 @@ define_layout_target!(
|
||||
WelcomeScreenButtons,
|
||||
/// The color swatch for the working colors and a flip and reset button found at the bottom of the tool shelf.
|
||||
WorkingColors,
|
||||
);
|
||||
|
||||
// KEEP THIS ENUM LAST
|
||||
// This is a marker that is used to define an array that is used to hold widgets
|
||||
_LayoutTargetLength,
|
||||
}
|
||||
|
||||
/// For use by structs that define a UI widget layout by implementing the layout() function belonging to this trait.
|
||||
/// The send_layout() function can then be called by other code which is a part of the same struct so as to send the layout to the frontend.
|
||||
@@ -169,8 +151,7 @@ fn compute_checkbox_id(layout_target: LayoutTarget, widget_path: &[usize], widge
|
||||
}
|
||||
|
||||
/// Contains an arrangement of widgets mounted somewhere specific in the frontend.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize, PartialEq)]
|
||||
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize, PartialEq, specta::Type)]
|
||||
pub struct Layout(pub Vec<LayoutGroup>);
|
||||
|
||||
impl Layout {
|
||||
@@ -260,19 +241,19 @@ impl<'a> Iterator for WidgetIter<'a> {
|
||||
}
|
||||
|
||||
match self.stack.pop() {
|
||||
Some(LayoutGroup::Column(WidgetColumn { widgets })) => {
|
||||
Some(LayoutGroup::Column { widgets }) => {
|
||||
self.current_slice = Some(widgets);
|
||||
self.next()
|
||||
}
|
||||
Some(LayoutGroup::Row(WidgetRow { widgets })) => {
|
||||
Some(LayoutGroup::Row { widgets }) => {
|
||||
self.current_slice = Some(widgets);
|
||||
self.next()
|
||||
}
|
||||
Some(LayoutGroup::Table(WidgetTable { rows, .. })) => {
|
||||
Some(LayoutGroup::Table { rows, .. }) => {
|
||||
self.table.extend(rows.iter().flatten().rev());
|
||||
self.next()
|
||||
}
|
||||
Some(LayoutGroup::Section(WidgetSection { layout, .. })) => {
|
||||
Some(LayoutGroup::Section { layout, .. }) => {
|
||||
for layout_row in &layout.0 {
|
||||
self.stack.push(layout_row);
|
||||
}
|
||||
@@ -312,19 +293,19 @@ impl<'a> Iterator for WidgetIterMut<'a> {
|
||||
}
|
||||
|
||||
match self.stack.pop() {
|
||||
Some(LayoutGroup::Column(WidgetColumn { widgets })) => {
|
||||
Some(LayoutGroup::Column { widgets }) => {
|
||||
self.current_slice = Some(widgets);
|
||||
self.next()
|
||||
}
|
||||
Some(LayoutGroup::Row(WidgetRow { widgets })) => {
|
||||
Some(LayoutGroup::Row { widgets }) => {
|
||||
self.current_slice = Some(widgets);
|
||||
self.next()
|
||||
}
|
||||
Some(LayoutGroup::Table(WidgetTable { rows, .. })) => {
|
||||
Some(LayoutGroup::Table { rows, .. }) => {
|
||||
self.table.extend(rows.iter_mut().flatten().rev());
|
||||
self.next()
|
||||
}
|
||||
Some(LayoutGroup::Section(WidgetSection { layout, .. })) => {
|
||||
Some(LayoutGroup::Section { layout, .. }) => {
|
||||
for layout_row in &mut layout.0 {
|
||||
self.stack.push(layout_row);
|
||||
}
|
||||
@@ -335,88 +316,52 @@ impl<'a> Iterator for WidgetIterMut<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum LayoutGroup {
|
||||
Column(WidgetColumn),
|
||||
Row(WidgetRow),
|
||||
Table(WidgetTable),
|
||||
Section(WidgetSection),
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Default, Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct WidgetColumn {
|
||||
#[serde(rename = "columnWidgets")]
|
||||
pub widgets: Vec<WidgetInstance>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Default, Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct WidgetRow {
|
||||
#[serde(rename = "rowWidgets")]
|
||||
pub widgets: Vec<WidgetInstance>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Default, Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct WidgetTable {
|
||||
#[serde(rename = "tableWidgets")]
|
||||
pub rows: Vec<Vec<WidgetInstance>>,
|
||||
pub unstyled: bool,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct WidgetSection {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub visible: bool,
|
||||
pub pinned: bool,
|
||||
pub id: u64,
|
||||
pub layout: Layout,
|
||||
#[serde(rename = "column")]
|
||||
Column {
|
||||
#[serde(rename = "columnWidgets")]
|
||||
widgets: Vec<WidgetInstance>,
|
||||
},
|
||||
#[serde(rename = "row")]
|
||||
Row {
|
||||
#[serde(rename = "rowWidgets")]
|
||||
widgets: Vec<WidgetInstance>,
|
||||
},
|
||||
#[serde(rename = "table")]
|
||||
Table {
|
||||
#[serde(rename = "tableWidgets")]
|
||||
rows: Vec<Vec<WidgetInstance>>,
|
||||
unstyled: bool,
|
||||
},
|
||||
#[serde(rename = "section")]
|
||||
Section {
|
||||
name: String,
|
||||
description: String,
|
||||
visible: bool,
|
||||
pinned: bool,
|
||||
id: u64,
|
||||
layout: Layout,
|
||||
},
|
||||
}
|
||||
|
||||
impl Default for LayoutGroup {
|
||||
fn default() -> Self {
|
||||
Self::Row(Default::default())
|
||||
Self::Row { widgets: Vec::new() }
|
||||
}
|
||||
}
|
||||
impl From<Vec<WidgetInstance>> for LayoutGroup {
|
||||
fn from(widgets: Vec<WidgetInstance>) -> LayoutGroup {
|
||||
LayoutGroup::Row(WidgetRow { widgets })
|
||||
LayoutGroup::Row { widgets }
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutGroup {
|
||||
pub fn row(widgets: Vec<WidgetInstance>) -> Self {
|
||||
Self::Row(WidgetRow { widgets })
|
||||
}
|
||||
|
||||
pub fn column(widgets: Vec<WidgetInstance>) -> Self {
|
||||
Self::Column(WidgetColumn { widgets })
|
||||
}
|
||||
|
||||
pub fn table(rows: Vec<Vec<WidgetInstance>>, unstyled: bool) -> Self {
|
||||
Self::Table(WidgetTable { rows, unstyled })
|
||||
}
|
||||
|
||||
pub fn section(name: impl Into<String>, description: impl Into<String>, visible: bool, pinned: bool, id: u64, layout: Layout) -> Self {
|
||||
Self::Section(WidgetSection {
|
||||
name: name.into(),
|
||||
description: description.into(),
|
||||
visible,
|
||||
pinned,
|
||||
id,
|
||||
layout,
|
||||
})
|
||||
}
|
||||
|
||||
/// Applies a tooltip description to all widgets without a tooltip in this row or column.
|
||||
pub fn with_tooltip_description(self, description: impl Into<String>) -> Self {
|
||||
let (is_col, mut widgets) = match self {
|
||||
LayoutGroup::Column(WidgetColumn { widgets }) => (true, widgets),
|
||||
LayoutGroup::Row(WidgetRow { widgets }) => (false, widgets),
|
||||
LayoutGroup::Column { widgets } => (true, widgets),
|
||||
LayoutGroup::Row { widgets } => (false, widgets),
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
let description = description.into();
|
||||
@@ -449,7 +394,7 @@ impl LayoutGroup {
|
||||
val.clone_from(&description);
|
||||
}
|
||||
}
|
||||
if is_col { Self::Column(WidgetColumn { widgets }) } else { Self::Row(WidgetRow { widgets }) }
|
||||
if is_col { Self::Column { widgets } } else { Self::Row { widgets } }
|
||||
}
|
||||
|
||||
pub fn iter_mut(&mut self) -> WidgetIterMut<'_> {
|
||||
@@ -468,8 +413,7 @@ impl Diffable for LayoutGroup {
|
||||
fn diff(&mut self, new: Self, widget_path: &mut Vec<usize>, widget_diffs: &mut Vec<WidgetDiff>) {
|
||||
let is_column = matches!(new, Self::Column { .. });
|
||||
match (self, new) {
|
||||
(Self::Column(WidgetColumn { widgets: current_widgets }), Self::Column(WidgetColumn { widgets: new_widgets }))
|
||||
| (Self::Row(WidgetRow { widgets: current_widgets }), Self::Row(WidgetRow { widgets: new_widgets })) => {
|
||||
(Self::Column { widgets: current_widgets }, Self::Column { widgets: new_widgets }) | (Self::Row { widgets: current_widgets }, Self::Row { widgets: new_widgets }) => {
|
||||
// If the lengths are different then resend the entire panel
|
||||
// TODO: Diff insersion and deletion of items
|
||||
if current_widgets.len() != new_widgets.len() {
|
||||
@@ -477,12 +421,7 @@ impl Diffable for LayoutGroup {
|
||||
current_widgets.clone_from(&new_widgets);
|
||||
|
||||
// Push back a LayoutGroup update to the diff
|
||||
let new_value = (if is_column {
|
||||
Self::Column(WidgetColumn { widgets: new_widgets })
|
||||
} else {
|
||||
Self::Row(WidgetRow { widgets: new_widgets })
|
||||
})
|
||||
.into_diff_update();
|
||||
let new_value = (if is_column { Self::Column { widgets: new_widgets } } else { Self::Row { widgets: new_widgets } }).into_diff_update();
|
||||
let widget_path = widget_path.to_vec();
|
||||
widget_diffs.push(WidgetDiff { widget_path, new_value });
|
||||
return;
|
||||
@@ -495,22 +434,22 @@ impl Diffable for LayoutGroup {
|
||||
}
|
||||
}
|
||||
(
|
||||
Self::Section(WidgetSection {
|
||||
Self::Section {
|
||||
name: current_name,
|
||||
description: current_description,
|
||||
visible: current_visible,
|
||||
pinned: current_pinned,
|
||||
id: current_id,
|
||||
layout: current_layout,
|
||||
}),
|
||||
Self::Section(WidgetSection {
|
||||
},
|
||||
Self::Section {
|
||||
name: new_name,
|
||||
description: new_description,
|
||||
visible: new_visible,
|
||||
pinned: new_pinned,
|
||||
id: new_id,
|
||||
layout: new_layout,
|
||||
}),
|
||||
},
|
||||
) => {
|
||||
// Resend the entire panel if the lengths, names, visibility, or node IDs are different
|
||||
// TODO: Diff insersion and deletion of items
|
||||
@@ -530,14 +469,14 @@ impl Diffable for LayoutGroup {
|
||||
current_layout.clone_from(&new_layout);
|
||||
|
||||
// Push an update layout group to the diff
|
||||
let new_value = Self::Section(WidgetSection {
|
||||
let new_value = Self::Section {
|
||||
name: new_name,
|
||||
description: new_description,
|
||||
visible: new_visible,
|
||||
pinned: new_pinned,
|
||||
id: new_id,
|
||||
layout: new_layout,
|
||||
})
|
||||
}
|
||||
.into_diff_update();
|
||||
let widget_path = widget_path.to_vec();
|
||||
widget_diffs.push(WidgetDiff { widget_path, new_value });
|
||||
@@ -562,14 +501,14 @@ impl Diffable for LayoutGroup {
|
||||
|
||||
fn collect_checkbox_ids(&self, layout_target: LayoutTarget, widget_path: &mut Vec<usize>, checkbox_map: &mut HashMap<CheckboxId, CheckboxId>) {
|
||||
match self {
|
||||
Self::Column(WidgetColumn { widgets }) | Self::Row(WidgetRow { widgets }) => {
|
||||
Self::Column { widgets } | Self::Row { widgets } => {
|
||||
for (index, widget) in widgets.iter().enumerate() {
|
||||
widget_path.push(index);
|
||||
widget.collect_checkbox_ids(layout_target, widget_path, checkbox_map);
|
||||
widget_path.pop();
|
||||
}
|
||||
}
|
||||
Self::Table(WidgetTable { rows, .. }) => {
|
||||
Self::Table { rows, .. } => {
|
||||
for (row_idx, row) in rows.iter().enumerate() {
|
||||
for (col_idx, widget) in row.iter().enumerate() {
|
||||
widget_path.push(row_idx);
|
||||
@@ -580,7 +519,7 @@ impl Diffable for LayoutGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
Self::Section(WidgetSection { layout, .. }) => {
|
||||
Self::Section { layout, .. } => {
|
||||
layout.collect_checkbox_ids(layout_target, widget_path, checkbox_map);
|
||||
}
|
||||
}
|
||||
@@ -588,14 +527,14 @@ impl Diffable for LayoutGroup {
|
||||
|
||||
fn replace_widget_ids(&mut self, layout_target: LayoutTarget, widget_path: &mut Vec<usize>, checkbox_map: &HashMap<CheckboxId, CheckboxId>) {
|
||||
match self {
|
||||
Self::Column(WidgetColumn { widgets }) | Self::Row(WidgetRow { widgets }) => {
|
||||
Self::Column { widgets } | Self::Row { widgets } => {
|
||||
for (index, widget) in widgets.iter_mut().enumerate() {
|
||||
widget_path.push(index);
|
||||
widget.replace_widget_ids(layout_target, widget_path, checkbox_map);
|
||||
widget_path.pop();
|
||||
}
|
||||
}
|
||||
Self::Table(WidgetTable { rows, .. }) => {
|
||||
Self::Table { rows, .. } => {
|
||||
for (row_idx, row) in rows.iter_mut().enumerate() {
|
||||
for (col_idx, widget) in row.iter_mut().enumerate() {
|
||||
widget_path.push(row_idx);
|
||||
@@ -606,15 +545,14 @@ impl Diffable for LayoutGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
Self::Section(WidgetSection { layout, .. }) => {
|
||||
Self::Section { layout, .. } => {
|
||||
layout.replace_widget_ids(layout_target, widget_path, checkbox_map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct WidgetInstance {
|
||||
#[serde(rename = "widgetId")]
|
||||
pub widget_id: WidgetId,
|
||||
@@ -736,8 +674,9 @@ impl Diffable for WidgetInstance {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, specta::Type)]
|
||||
pub struct WidgetCallback<T> {
|
||||
#[specta(skip)]
|
||||
pub callback: Arc<dyn Fn(&T) -> Message + 'static + Send + Sync>,
|
||||
}
|
||||
|
||||
@@ -753,8 +692,7 @@ impl<T> Default for WidgetCallback<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum Widget {
|
||||
BreadcrumbTrailButtons(BreadcrumbTrailButtons),
|
||||
CheckboxInput(CheckboxInput),
|
||||
@@ -781,8 +719,7 @@ pub enum Widget {
|
||||
}
|
||||
|
||||
/// A single change to part of the UI, containing the location of the change and the new value.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct WidgetDiff {
|
||||
/// A path to the change
|
||||
/// e.g. [0, 1, 2] in the properties panel is the first section, second row and third widget.
|
||||
@@ -795,8 +732,7 @@ pub struct WidgetDiff {
|
||||
}
|
||||
|
||||
/// The new value of the UI, sent as part of a diff.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum DiffUpdate {
|
||||
#[serde(rename = "layout")]
|
||||
Layout(Layout),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::messages::frontend::IconName;
|
||||
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::node_graph::utility_types::FrontendGraphDataType;
|
||||
@@ -7,14 +6,12 @@ use derivative::*;
|
||||
use graphene_std::vector::style::FillChoice;
|
||||
use graphite_proc_macros::WidgetBuilder;
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct IconButton {
|
||||
// Content
|
||||
#[widget_builder(constructor)]
|
||||
#[widget_builder(string)]
|
||||
pub icon: IconName,
|
||||
pub icon: String,
|
||||
#[serde(rename = "hoverIcon")]
|
||||
pub hover_icon: Option<String>,
|
||||
#[widget_builder(constructor)]
|
||||
@@ -41,14 +38,12 @@ pub struct IconButton {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct PopoverButton {
|
||||
// Content
|
||||
pub style: Option<String>,
|
||||
#[widget_builder(string)]
|
||||
pub icon: Option<IconName>,
|
||||
pub icon: Option<String>,
|
||||
pub disabled: bool,
|
||||
|
||||
// Children
|
||||
@@ -68,8 +63,7 @@ pub struct PopoverButton {
|
||||
pub tooltip_shortcut: Option<ActionShortcut>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Default, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Default, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum MenuDirection {
|
||||
Top,
|
||||
#[default]
|
||||
@@ -83,8 +77,7 @@ pub enum MenuDirection {
|
||||
Center,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct ParameterExposeButton {
|
||||
// Content
|
||||
@@ -109,15 +102,13 @@ pub struct ParameterExposeButton {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct TextButton {
|
||||
// Content
|
||||
#[widget_builder(constructor)]
|
||||
pub label: String,
|
||||
#[widget_builder(string)]
|
||||
pub icon: Option<IconName>,
|
||||
pub icon: Option<String>,
|
||||
#[serde(rename = "hoverIcon")]
|
||||
pub hover_icon: Option<String>,
|
||||
pub disabled: bool,
|
||||
@@ -155,8 +146,7 @@ pub struct TextButton {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct ImageButton {
|
||||
// Content
|
||||
@@ -182,8 +172,7 @@ pub struct ImageButton {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||
#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct ColorInput {
|
||||
// Content
|
||||
@@ -218,8 +207,7 @@ pub struct ColorInput {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct BreadcrumbTrailButtons {
|
||||
// Content
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::messages::frontend::IconName;
|
||||
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier;
|
||||
@@ -8,15 +7,14 @@ use graphene_std::raster::curve::Curve;
|
||||
use graphene_std::transform::ReferencePoint;
|
||||
use graphite_proc_macros::WidgetBuilder;
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||
#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, Default, PartialEq)]
|
||||
pub struct CheckboxInput {
|
||||
// Content
|
||||
#[widget_builder(constructor)]
|
||||
pub checked: bool,
|
||||
#[widget_builder(string)]
|
||||
pub icon: Option<IconName>,
|
||||
#[derivative(Default(value = "\"Checkmark\".to_string()"))]
|
||||
pub icon: String,
|
||||
#[serde(rename = "forLabel")]
|
||||
pub for_label: CheckboxId,
|
||||
pub disabled: bool,
|
||||
@@ -38,7 +36,6 @@ pub struct CheckboxInput {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
pub struct CheckboxId(pub u64);
|
||||
|
||||
@@ -52,9 +49,14 @@ impl Default for CheckboxId {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
impl specta::Type for CheckboxId {
|
||||
fn inline(_type_map: &mut specta::TypeCollection, _generics: specta::Generics) -> specta::datatype::DataType {
|
||||
// TODO: This might not be right, but it works for now. We just need the type `bigint | undefined`.
|
||||
specta::datatype::DataType::Primitive(specta::datatype::PrimitiveType::u64)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct DropdownInput {
|
||||
// Content
|
||||
@@ -100,8 +102,7 @@ pub struct DropdownInput {
|
||||
|
||||
pub type MenuListEntrySections = Vec<Vec<MenuListEntry>>;
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
#[widget_builder(not_widget_instance)]
|
||||
pub struct MenuListEntry {
|
||||
@@ -109,8 +110,7 @@ pub struct MenuListEntry {
|
||||
#[widget_builder(constructor)]
|
||||
pub value: String,
|
||||
pub label: String,
|
||||
#[widget_builder(string)]
|
||||
pub icon: Option<IconName>,
|
||||
pub icon: String,
|
||||
pub disabled: bool,
|
||||
|
||||
// Children
|
||||
@@ -120,7 +120,7 @@ pub struct MenuListEntry {
|
||||
pub children_hash: u64,
|
||||
|
||||
// Styling
|
||||
pub font: Option<String>,
|
||||
pub font: String,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
@@ -148,8 +148,7 @@ impl std::hash::Hash for MenuListEntry {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct NumberInput {
|
||||
// Content
|
||||
@@ -247,30 +246,22 @@ impl NumberInput {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Debug, Default, PartialEq, Eq)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Debug, Default, PartialEq, Eq, specta::Type)]
|
||||
pub enum NumberInputIncrementBehavior {
|
||||
/// The value is added by `step`.
|
||||
#[default]
|
||||
Add,
|
||||
/// The value is multiplied by `step`.
|
||||
Multiply,
|
||||
/// The functions `incrementCallbackIncrease` and `incrementCallbackDecrease` call custom behavior.
|
||||
Callback,
|
||||
/// The increment arrows are not shown.
|
||||
None,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Debug, Default, PartialEq, Eq)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Debug, Default, PartialEq, Eq, specta::Type)]
|
||||
pub enum NumberInputMode {
|
||||
#[default]
|
||||
Increment,
|
||||
Range,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct NodeCatalog {
|
||||
// Content
|
||||
@@ -289,8 +280,7 @@ pub struct NodeCatalog {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct RadioInput {
|
||||
// Content
|
||||
@@ -313,8 +303,7 @@ pub struct RadioInput {
|
||||
// Callbacks exists on the `RadioEntryData` children, not this parent `RadioInput`
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
#[widget_builder(not_widget_instance)]
|
||||
pub struct RadioEntryData {
|
||||
@@ -322,8 +311,7 @@ pub struct RadioEntryData {
|
||||
#[widget_builder(constructor)]
|
||||
pub value: String,
|
||||
pub label: String,
|
||||
#[widget_builder(string)]
|
||||
pub icon: Option<IconName>,
|
||||
pub icon: String,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
@@ -342,8 +330,7 @@ pub struct RadioEntryData {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct WorkingColorsInput {
|
||||
// Content
|
||||
@@ -353,8 +340,7 @@ pub struct WorkingColorsInput {
|
||||
pub secondary: Color,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct TextAreaInput {
|
||||
// Content
|
||||
@@ -380,8 +366,7 @@ pub struct TextAreaInput {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct TextInput {
|
||||
// Content
|
||||
@@ -418,8 +403,7 @@ pub struct TextInput {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq, Default)]
|
||||
pub struct CurveInput {
|
||||
// Content
|
||||
@@ -443,8 +427,7 @@ pub struct CurveInput {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct ReferencePointInput {
|
||||
// Content
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use super::input_widgets::CheckboxId;
|
||||
use crate::messages::{frontend::IconName, input_mapper::utility_types::misc::ActionShortcut};
|
||||
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
||||
use derivative::*;
|
||||
use graphite_proc_macros::WidgetBuilder;
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Default, PartialEq, Eq, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Default, PartialEq, Eq, WidgetBuilder, specta::Type)]
|
||||
pub struct IconLabel {
|
||||
// Content
|
||||
#[widget_builder(constructor)]
|
||||
#[widget_builder(string)]
|
||||
pub icon: IconName,
|
||||
pub icon: String,
|
||||
pub disabled: bool,
|
||||
|
||||
// Tooltips
|
||||
@@ -21,8 +19,7 @@ pub struct IconLabel {
|
||||
pub tooltip_shortcut: Option<ActionShortcut>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
||||
pub struct Separator {
|
||||
// Content
|
||||
pub direction: SeparatorDirection,
|
||||
@@ -30,16 +27,14 @@ pub struct Separator {
|
||||
pub style: SeparatorStyle,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum SeparatorDirection {
|
||||
#[default]
|
||||
Horizontal,
|
||||
Vertical,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum SeparatorStyle {
|
||||
Related,
|
||||
#[default]
|
||||
@@ -47,8 +42,7 @@ pub enum SeparatorStyle {
|
||||
Section,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Eq, Default, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Eq, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(PartialEq)]
|
||||
pub struct TextLabel {
|
||||
// Content
|
||||
@@ -84,8 +78,7 @@ pub struct TextLabel {
|
||||
pub tooltip_shortcut: Option<ActionShortcut>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct ImageLabel {
|
||||
// Content
|
||||
@@ -103,8 +96,7 @@ pub struct ImageLabel {
|
||||
pub tooltip_shortcut: Option<ActionShortcut>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct ShortcutLabel {
|
||||
// Content
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::messages::input_mapper::utility_types::macros::action_shortcut;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate, AlignAxis, FlipAxis, GroupFolderType};
|
||||
use crate::messages::prelude::*;
|
||||
use graphene_std::vector::misc::BooleanOperation;
|
||||
use graphene_std::path_bool::BooleanOperation;
|
||||
|
||||
#[derive(Debug, Clone, Default, ExtractField)]
|
||||
pub struct MenuBarMessageHandler {
|
||||
@@ -76,7 +76,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
||||
TextButton::new("Graphite")
|
||||
.label("")
|
||||
.flush(true)
|
||||
.icon("GraphiteLogo")
|
||||
.icon(Some("GraphiteLogo".into()))
|
||||
.on_commit(|_| FrontendMessage::TriggerVisitLink { url: "https://graphite.art".into() }.into())
|
||||
.widget_instance(),
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -750,6 +750,6 @@ impl LayoutHolder for MenuBarMessageHandler {
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
Layout(vec![LayoutGroup::row(menu_bar_buttons)])
|
||||
Layout(vec![LayoutGroup::Row { widgets: menu_bar_buttons }])
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,14 @@ pub enum Message {
|
||||
NoOp,
|
||||
}
|
||||
|
||||
/// Provides an impl of `specta::Type` for `MessageDiscriminant`, the struct created by `impl_message`.
|
||||
/// Specta isn't integrated with `impl_message`, so a remote impl must be provided using this struct.
|
||||
impl specta::Type for MessageDiscriminant {
|
||||
fn inline(_type_map: &mut specta::TypeCollection, _generics: specta::Generics) -> specta::DataType {
|
||||
specta::DataType::Any
|
||||
}
|
||||
}
|
||||
|
||||
impl Message {
|
||||
pub fn message_tree() -> DebugMessageTree {
|
||||
Self::build_message_tree()
|
||||
|
||||
@@ -128,7 +128,7 @@ impl DataPanelMessageHandler {
|
||||
}
|
||||
|
||||
if !widgets.is_empty() {
|
||||
layout.0.insert(0, LayoutGroup::row(widgets));
|
||||
layout.0.insert(0, LayoutGroup::Row { widgets });
|
||||
}
|
||||
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
@@ -185,7 +185,7 @@ fn column_headings(value: &[&str]) -> Vec<WidgetInstance> {
|
||||
|
||||
fn label(x: impl Into<String>) -> Vec<LayoutGroup> {
|
||||
let error = vec![TextLabel::new(x).widget_instance()];
|
||||
vec![LayoutGroup::row(error)]
|
||||
vec![LayoutGroup::Row { widgets: error }]
|
||||
}
|
||||
|
||||
trait TableRowLayout {
|
||||
@@ -234,7 +234,7 @@ impl<T: TableRowLayout> TableRowLayout for Vec<T> {
|
||||
|
||||
rows.insert(0, column_headings(&["", "element"]));
|
||||
|
||||
vec![LayoutGroup::table(rows, false)]
|
||||
vec![LayoutGroup::Table { rows, unstyled: false }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ impl<T: TableRowLayout> TableRowLayout for Table<T> {
|
||||
|
||||
rows.insert(0, column_headings(&["", "element", "transform", "alpha_blending", "source_node_id"]));
|
||||
|
||||
vec![LayoutGroup::table(rows, false)]
|
||||
vec![LayoutGroup::Table { rows, unstyled: false }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ impl TableRowLayout for Vector {
|
||||
}
|
||||
}
|
||||
|
||||
vec![LayoutGroup::row(table_tabs), LayoutGroup::table(table_rows, false)]
|
||||
vec![LayoutGroup::Row { widgets: table_tabs }, LayoutGroup::Table { rows: table_rows, unstyled: false }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ impl TableRowLayout for Raster<CPU> {
|
||||
|
||||
if raster.width == 0 || raster.height == 0 {
|
||||
let widgets = vec![TextLabel::new("Image has no area").widget_instance()];
|
||||
return vec![LayoutGroup::row(widgets)];
|
||||
return vec![LayoutGroup::Row { widgets }];
|
||||
}
|
||||
|
||||
let base64_string = raster.base64_string.clone().unwrap_or_else(|| {
|
||||
@@ -519,7 +519,7 @@ impl TableRowLayout for Raster<CPU> {
|
||||
});
|
||||
|
||||
let widgets = vec![ImageLabel::new(base64_string).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ impl TableRowLayout for Raster<GPU> {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new("Raster is a texture on the GPU and cannot currently be displayed here").widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,7 +552,7 @@ impl TableRowLayout for Color {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![self.element_widget(0)];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ impl TableRowLayout for GradientStops {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![self.element_widget(0)];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,7 +585,7 @@ impl TableRowLayout for f64 {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ impl TableRowLayout for u32 {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,7 +611,7 @@ impl TableRowLayout for u64 {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,7 +624,7 @@ impl TableRowLayout for bool {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,7 +643,7 @@ impl TableRowLayout for String {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextAreaInput::new(self.to_string()).disabled(true).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -656,7 +656,7 @@ impl TableRowLayout for Option<f64> {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(format!("{self:?}")).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,7 +669,7 @@ impl TableRowLayout for DVec2 {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(format!("({}, {})", self.x, self.y)).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,7 +682,7 @@ impl TableRowLayout for Vec2 {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(format!("({}, {})", self.x, self.y)).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,7 +695,7 @@ impl TableRowLayout for DAffine2 {
|
||||
}
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let widgets = vec![TextLabel::new(format_transform_matrix(self)).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,7 +709,7 @@ impl TableRowLayout for Affine2 {
|
||||
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
let matrix = DAffine2::from_cols_array(&self.to_cols_array().map(|x| x as f64));
|
||||
let widgets = vec![TextLabel::new(format_transform_matrix(&matrix)).widget_instance()];
|
||||
vec![LayoutGroup::row(widgets)]
|
||||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::node_graph::document_node_definitions;
|
||||
use super::node_graph::utility_types::Transform;
|
||||
use super::utility_types::error::EditorError;
|
||||
use super::utility_types::misc::{GroupFolderType, SNAP_FUNCTIONS_FOR_BOUNDING_BOXES, SNAP_FUNCTIONS_FOR_PATHS, SnappingOptions, SnappingState};
|
||||
use super::utility_types::network_interface::{self, NodeNetworkInterface, TransactionStatus};
|
||||
@@ -29,7 +30,7 @@ use glam::{DAffine2, DVec2, IVec2};
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork};
|
||||
use graphene_std::math::quad::Quad;
|
||||
use graphene_std::path_bool_nodes::boolean_intersect;
|
||||
use graphene_std::path_bool::{boolean_intersect, path_bool_lib};
|
||||
use graphene_std::raster::BlendMode;
|
||||
use graphene_std::raster_types::Raster;
|
||||
use graphene_std::render_node::wgpu_available;
|
||||
@@ -37,9 +38,9 @@ use graphene_std::subpath::Subpath;
|
||||
use graphene_std::table::Table;
|
||||
use graphene_std::vector::PointId;
|
||||
use graphene_std::vector::click_target::{ClickTarget, ClickTargetType};
|
||||
use graphene_std::vector::misc::dvec2_to_point;
|
||||
use graphene_std::vector::misc::{dvec2_to_point, point_to_dvec2};
|
||||
use graphene_std::vector::style::RenderMode;
|
||||
use kurbo::{Affine, BezPath, Line, PathSeg};
|
||||
use kurbo::{Affine, CubicBez, Line, ParamCurve, PathSeg, QuadBez};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -589,7 +590,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
responses.add(DocumentMessage::RenderScrollbars);
|
||||
if opened {
|
||||
responses.add(NodeGraphMessage::UnloadWires);
|
||||
responses.add(NodeGraphMessage::UpdateNodeGraphWidth);
|
||||
}
|
||||
if open {
|
||||
responses.add(ToolMessage::DeactivateTools);
|
||||
@@ -835,28 +835,26 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
});
|
||||
}
|
||||
DocumentMessage::SaveDocument | DocumentMessage::SaveDocumentAs => {
|
||||
responses.add(PortfolioMessage::AutoSaveActiveDocument);
|
||||
|
||||
let path = if let DocumentMessage::SaveDocumentAs = message { None } else { self.path.clone() };
|
||||
if path.is_some() {
|
||||
responses.add(DocumentMessage::MarkAsSaved);
|
||||
if let DocumentMessage::SaveDocumentAs = message {
|
||||
self.path = None;
|
||||
}
|
||||
|
||||
let folder = self.path.as_ref().and_then(|path| path.parent()).map(|parent| parent.to_path_buf());
|
||||
self.set_save_state(true);
|
||||
responses.add(PortfolioMessage::AutoSaveActiveDocument);
|
||||
// Update the save status of the just saved document
|
||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||
|
||||
responses.add(FrontendMessage::TriggerSaveDocument {
|
||||
document_id,
|
||||
name: format!("{}.{}", self.name.clone(), FILE_EXTENSION),
|
||||
path,
|
||||
folder,
|
||||
content: self.serialize_document().into_bytes().into(),
|
||||
});
|
||||
path: self.path.clone(),
|
||||
content: self.serialize_document().into_bytes(),
|
||||
})
|
||||
}
|
||||
DocumentMessage::SavedDocument { path } => {
|
||||
self.path = path;
|
||||
|
||||
responses.add(PortfolioMessage::AutoSaveActiveDocument);
|
||||
responses.add(DocumentMessage::MarkAsSaved);
|
||||
|
||||
// Update the name to match the file stem
|
||||
let document_name_from_path = self.path.as_ref().and_then(|path| {
|
||||
@@ -1334,8 +1332,11 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
responses.add(NodeGraphMessage::UpdateImportsExports);
|
||||
|
||||
responses.add(FrontendMessage::UpdateNodeGraphTransform {
|
||||
translation: transform.translation.into(),
|
||||
scale: transform.matrix2.x_axis.x,
|
||||
transform: Transform {
|
||||
scale: transform.matrix2.x_axis.x,
|
||||
x: transform.translation.x,
|
||||
y: transform.translation.y,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -2215,222 +2216,256 @@ impl DocumentMessageHandler {
|
||||
.widget_instance(),
|
||||
PopoverButton::new()
|
||||
.popover_layout(Layout(vec![
|
||||
LayoutGroup::row(vec![TextLabel::new("Overlays").bold(true).widget_instance()]),
|
||||
LayoutGroup::row(vec![TextLabel::new("General").widget_instance()]),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.artboard_name)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::ArtboardName),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Artboard Name".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.transform_measurement)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::TransformMeasurement),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("G/R/S Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row(vec![TextLabel::new("Select Tool").widget_instance()]),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.quick_measurement)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::QuickMeasurement),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Quick Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.transform_cage)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::TransformCage),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Cage".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.compass_rose)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::CompassRose),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Dial".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.pivot)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Pivot),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Pivot".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.origin)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Origin),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Origin".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.hover_outline)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::HoverOutline),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Hover Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.selection_outline)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::SelectionOutline),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Selection Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.layer_origin_cross)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::LayerOriginCross),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Layer Origin".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row(vec![TextLabel::new("Pen & Path Tools").widget_instance()]),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.path)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Path),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Path".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.anchors)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Anchors),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Anchors".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::row({
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.handles)
|
||||
.disabled(!self.overlays_visibility_settings.anchors)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Handles),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Handles".to_string())
|
||||
.disabled(!self.overlays_visibility_settings.anchors)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
]
|
||||
}),
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Overlays").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("General").widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.artboard_name)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::ArtboardName),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Artboard Name".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.transform_measurement)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::TransformMeasurement),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("G/R/S Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Select Tool").widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.quick_measurement)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::QuickMeasurement),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Quick Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.transform_cage)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::TransformCage),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Cage".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.compass_rose)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::CompassRose),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Dial".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.pivot)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Pivot),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Pivot".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.pivot)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Origin),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Transform Origin".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.hover_outline)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::HoverOutline),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Hover Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.selection_outline)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::SelectionOutline),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Selection Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.layer_origin_cross)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::LayerOriginCross),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Layer Origin".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Pen & Path Tools").widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.path)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Path),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Path".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.anchors)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Anchors),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Anchors".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(self.overlays_visibility_settings.handles)
|
||||
.disabled(!self.overlays_visibility_settings.anchors)
|
||||
.on_update(|optional_input: &CheckboxInput| {
|
||||
DocumentMessage::SetOverlaysVisibility {
|
||||
visible: optional_input.checked,
|
||||
overlays_type: Some(OverlaysType::Handles),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Handles".to_string())
|
||||
.disabled(!self.overlays_visibility_settings.anchors)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
]
|
||||
},
|
||||
},
|
||||
]))
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
@@ -2449,12 +2484,16 @@ impl DocumentMessageHandler {
|
||||
PopoverButton::new()
|
||||
.popover_layout(Layout(
|
||||
[
|
||||
LayoutGroup::row(vec![TextLabel::new("Snapping").bold(true).widget_instance()]),
|
||||
LayoutGroup::row(vec![TextLabel::new(SnappingOptions::BoundingBoxes.to_string()).widget_instance()]),
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Snapping").bold(true).widget_instance()],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(SnappingOptions::BoundingBoxes.to_string()).widget_instance()],
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
.chain(SNAP_FUNCTIONS_FOR_BOUNDING_BOXES.into_iter().map(|(name, closure, description)| {
|
||||
LayoutGroup::row({
|
||||
.chain(SNAP_FUNCTIONS_FOR_BOUNDING_BOXES.into_iter().map(|(name, closure, description)| LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(*closure(&mut snapping_state))
|
||||
@@ -2471,11 +2510,13 @@ impl DocumentMessageHandler {
|
||||
.widget_instance(),
|
||||
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
})
|
||||
},
|
||||
}))
|
||||
.chain([LayoutGroup::row(vec![TextLabel::new(SnappingOptions::Paths.to_string()).widget_instance()])])
|
||||
.chain(SNAP_FUNCTIONS_FOR_PATHS.into_iter().map(|(name, closure, description)| {
|
||||
LayoutGroup::row({
|
||||
.chain([LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new(SnappingOptions::Paths.to_string()).widget_instance()],
|
||||
}])
|
||||
.chain(SNAP_FUNCTIONS_FOR_PATHS.into_iter().map(|(name, closure, description)| LayoutGroup::Row {
|
||||
widgets: {
|
||||
let checkbox_id = CheckboxId::new();
|
||||
vec![
|
||||
CheckboxInput::new(*closure(&mut snapping_state2))
|
||||
@@ -2492,7 +2533,7 @@ impl DocumentMessageHandler {
|
||||
.widget_instance(),
|
||||
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_instance(),
|
||||
]
|
||||
})
|
||||
},
|
||||
}))
|
||||
.collect(),
|
||||
))
|
||||
@@ -2521,12 +2562,11 @@ impl DocumentMessageHandler {
|
||||
.icon("RenderModeOutline")
|
||||
.tooltip_label("Render Mode: Outline")
|
||||
.on_update(|_| DocumentMessage::SetRenderMode { render_mode: RenderMode::Outline }.into()),
|
||||
RadioEntryData::new("PixelPreview").icon("RenderModePixels").tooltip_label("Render Mode: Pixel Preview").on_update(|_| {
|
||||
DocumentMessage::SetRenderMode {
|
||||
render_mode: RenderMode::PixelPreview,
|
||||
}
|
||||
.into()
|
||||
}),
|
||||
// TODO: See issue #320
|
||||
// RadioEntryData::new("PixelPreview")
|
||||
// .icon("RenderModePixels")
|
||||
// .tooltip_label("Render Mode: Pixel Preview")
|
||||
// .on_update(|_| todo!()),
|
||||
RadioEntryData::new("SvgPreview")
|
||||
.icon("RenderModeSvg")
|
||||
.tooltip_label("Render Mode: SVG Preview")
|
||||
@@ -2537,7 +2577,7 @@ impl DocumentMessageHandler {
|
||||
if disabled {
|
||||
for entry in &mut entries {
|
||||
entry.tooltip_description = "
|
||||
*Normal*, *Outline*, and *Pixel Preview* render modes are not available in this browser. For compatibility, *SVG Preview* mode is active as a fallback.\n\
|
||||
*Normal* and *Outline* render modes are not available in this browser. For compatibility, *SVG Preview* mode is active as a fallback.\n\
|
||||
\n\
|
||||
This functionality requires WebGPU support. Check webgpu.org for browser implementation status.
|
||||
"
|
||||
@@ -2590,8 +2630,8 @@ impl DocumentMessageHandler {
|
||||
widgets.extend([
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
TextButton::new("Node Graph")
|
||||
.icon(if self.graph_view_overlay_open { "GraphViewOpen" } else { "GraphViewClosed" })
|
||||
.hover_icon(if self.graph_view_overlay_open { "GraphViewClosed" } else { "GraphViewOpen" })
|
||||
.icon(Some((if self.graph_view_overlay_open { "GraphViewOpen" } else { "GraphViewClosed" }).into()))
|
||||
.hover_icon(Some((if self.graph_view_overlay_open { "GraphViewClosed" } else { "GraphViewOpen" }).into()))
|
||||
.tooltip_label(if self.graph_view_overlay_open { "Hide Node Graph" } else { "Show Node Graph" })
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::GraphViewOverlayToggle))
|
||||
.on_update(move |_| DocumentMessage::GraphViewOverlayToggle.into())
|
||||
@@ -2599,7 +2639,7 @@ impl DocumentMessageHandler {
|
||||
]);
|
||||
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout(vec![LayoutGroup::row(widgets)]),
|
||||
layout: Layout(vec![LayoutGroup::Row { widgets }]),
|
||||
layout_target: LayoutTarget::DocumentBar,
|
||||
});
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
@@ -2737,25 +2777,25 @@ impl DocumentMessageHandler {
|
||||
.tooltip_label("Fill")
|
||||
.widget_instance(),
|
||||
];
|
||||
let layers_panel_control_bar_left = Layout(vec![LayoutGroup::row(widgets)]);
|
||||
let layers_panel_control_bar_left = Layout(vec![LayoutGroup::Row { widgets }]);
|
||||
|
||||
let widgets = vec![
|
||||
IconButton::new(if selection_all_locked { "PadlockLocked" } else { "PadlockUnlocked" }, 24)
|
||||
.hover_icon(if selection_all_locked { "PadlockUnlocked" } else { "PadlockLocked" })
|
||||
.hover_icon(Some((if selection_all_locked { "PadlockUnlocked" } else { "PadlockLocked" }).into()))
|
||||
.tooltip_label(if selection_all_locked { "Unlock Selected" } else { "Lock Selected" })
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ToggleSelectedLocked))
|
||||
.on_update(|_| NodeGraphMessage::ToggleSelectedLocked.into())
|
||||
.disabled(!has_selection)
|
||||
.widget_instance(),
|
||||
IconButton::new(if selection_all_visible { "EyeVisible" } else { "EyeHidden" }, 24)
|
||||
.hover_icon(if selection_all_visible { "EyeHide" } else { "EyeShow" })
|
||||
.hover_icon(Some((if selection_all_visible { "EyeHide" } else { "EyeShow" }).into()))
|
||||
.tooltip_label(if selection_all_visible { "Hide Selected" } else { "Show Selected" })
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ToggleSelectedVisibility))
|
||||
.on_update(|_| DocumentMessage::ToggleSelectedVisibility.into())
|
||||
.disabled(!has_selection)
|
||||
.widget_instance(),
|
||||
];
|
||||
let layers_panel_control_bar_right = Layout(vec![LayoutGroup::row(widgets)]);
|
||||
let layers_panel_control_bar_right = Layout(vec![LayoutGroup::Row { widgets }]);
|
||||
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: layers_panel_control_bar_left,
|
||||
@@ -2781,7 +2821,7 @@ impl DocumentMessageHandler {
|
||||
|
||||
let widgets = vec![
|
||||
PopoverButton::new()
|
||||
.icon("Node")
|
||||
.icon(Some("Node".to_string()))
|
||||
.menu_direction(Some(MenuDirection::Top))
|
||||
.tooltip_description("Add an operation to the end of this layer's chain of nodes.")
|
||||
.disabled(!has_selection || has_multiple_selection)
|
||||
@@ -2809,7 +2849,7 @@ impl DocumentMessageHandler {
|
||||
}
|
||||
})
|
||||
.widget_instance();
|
||||
Layout(vec![LayoutGroup::row(vec![node_chooser])])
|
||||
Layout(vec![LayoutGroup::Row { widgets: vec![node_chooser] }])
|
||||
})
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
@@ -2835,7 +2875,7 @@ impl DocumentMessageHandler {
|
||||
.widget_instance(),
|
||||
];
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout(vec![LayoutGroup::row(widgets)]),
|
||||
layout: Layout(vec![LayoutGroup::Row { widgets }]),
|
||||
layout_target: LayoutTarget::LayersPanelBottomBar,
|
||||
});
|
||||
}
|
||||
@@ -2984,7 +3024,7 @@ fn default_document_network_interface() -> NodeNetworkInterface {
|
||||
enum XRayTarget {
|
||||
Point(DVec2),
|
||||
Quad(Quad),
|
||||
Path(BezPath),
|
||||
Path(Vec<path_bool_lib::PathSegment>),
|
||||
Polygon(Subpath<PointId>),
|
||||
}
|
||||
|
||||
@@ -3002,12 +3042,17 @@ pub struct ClickXRayIter<'a> {
|
||||
parent_targets: Vec<(LayerNodeIdentifier, XRayTarget)>,
|
||||
}
|
||||
|
||||
fn quad_to_kurbo(quad: Quad) -> BezPath {
|
||||
BezPath::from_path_segments(quad.all_edges().into_iter().map(|[start, end]| PathSeg::Line(Line::new(dvec2_to_point(start), dvec2_to_point(end)))))
|
||||
fn quad_to_path_lib_segments(quad: Quad) -> Vec<path_bool_lib::PathSegment> {
|
||||
quad.all_edges().into_iter().map(|[start, end]| path_bool_lib::PathSegment::Line(start, end)).collect()
|
||||
}
|
||||
|
||||
fn click_targets_to_kurbo<'a>(click_targets: impl Iterator<Item = &'a ClickTarget>, transform: DAffine2) -> BezPath {
|
||||
let segments = click_targets
|
||||
fn click_targets_to_path_lib_segments<'a>(click_targets: impl Iterator<Item = &'a ClickTarget>, transform: DAffine2) -> Vec<path_bool_lib::PathSegment> {
|
||||
let segment = |bezier: PathSeg| match bezier {
|
||||
PathSeg::Line(line) => path_bool_lib::PathSegment::Line(point_to_dvec2(line.p0), point_to_dvec2(line.p1)),
|
||||
PathSeg::Quad(quad_bez) => path_bool_lib::PathSegment::Quadratic(point_to_dvec2(quad_bez.p0), point_to_dvec2(quad_bez.p1), point_to_dvec2(quad_bez.p2)),
|
||||
PathSeg::Cubic(cubic_bez) => path_bool_lib::PathSegment::Cubic(point_to_dvec2(cubic_bez.p0), point_to_dvec2(cubic_bez.p1), point_to_dvec2(cubic_bez.p2), point_to_dvec2(cubic_bez.p3)),
|
||||
};
|
||||
click_targets
|
||||
.filter_map(|target| {
|
||||
if let ClickTargetType::Subpath(subpath) = target.target_type() {
|
||||
Some(subpath.iter())
|
||||
@@ -3016,8 +3061,8 @@ fn click_targets_to_kurbo<'a>(click_targets: impl Iterator<Item = &'a ClickTarge
|
||||
}
|
||||
})
|
||||
.flatten()
|
||||
.map(|bezier| Affine::new(transform.to_cols_array()) * bezier);
|
||||
BezPath::from_path_segments(segments)
|
||||
.map(|bezier| segment(Affine::new(transform.to_cols_array()) * bezier))
|
||||
.collect()
|
||||
}
|
||||
|
||||
impl<'a> ClickXRayIter<'a> {
|
||||
@@ -3038,8 +3083,22 @@ impl<'a> ClickXRayIter<'a> {
|
||||
}
|
||||
|
||||
/// Handles the checking of the layer where the target is a rect or path
|
||||
fn check_layer_area_target(&mut self, click_targets: Option<&[Arc<ClickTarget>]>, clip: bool, layer: LayerNodeIdentifier, path: BezPath, transform: DAffine2) -> XRayResult {
|
||||
let get_clip = || path.segments();
|
||||
fn check_layer_area_target(
|
||||
&mut self,
|
||||
click_targets: Option<&[Arc<ClickTarget>]>,
|
||||
clip: bool,
|
||||
layer: LayerNodeIdentifier,
|
||||
path: Vec<path_bool_lib::PathSegment>,
|
||||
transform: DAffine2,
|
||||
) -> XRayResult {
|
||||
// Convert back to Kurbo types for intersections
|
||||
let segment = |bezier: &path_bool_lib::PathSegment| match *bezier {
|
||||
path_bool_lib::PathSegment::Line(start, end) => PathSeg::Line(Line::new(dvec2_to_point(start), dvec2_to_point(end))),
|
||||
path_bool_lib::PathSegment::Cubic(start, h1, h2, end) => PathSeg::Cubic(CubicBez::new(dvec2_to_point(start), dvec2_to_point(h1), dvec2_to_point(h2), dvec2_to_point(end))),
|
||||
path_bool_lib::PathSegment::Quadratic(start, h1, end) => PathSeg::Quad(QuadBez::new(dvec2_to_point(start), dvec2_to_point(h1), dvec2_to_point(end))),
|
||||
path_bool_lib::PathSegment::Arc(_, _, _, _, _, _, _) => unimplemented!(),
|
||||
};
|
||||
let get_clip = || path.iter().map(segment);
|
||||
|
||||
let intersects = click_targets.is_some_and(|targets| targets.iter().any(|target| target.intersect_path(get_clip, transform)));
|
||||
let clicked = intersects;
|
||||
@@ -3048,9 +3107,8 @@ impl<'a> ClickXRayIter<'a> {
|
||||
// In the case of a clip path where the area partially intersects, it is necessary to do a boolean operation.
|
||||
// We do this on this using the target area to reduce computation (as the target area is usually very simple).
|
||||
if clip && intersects {
|
||||
let clip_path = click_targets_to_kurbo(click_targets.iter().flat_map(|x| x.iter()).map(|x| x.as_ref()), transform);
|
||||
let intersection = boolean_intersect(&path, &clip_path);
|
||||
let subtracted = BezPath::from_path_segments(intersection.iter().flat_map(|p| p.segments()));
|
||||
let clip_path = click_targets_to_path_lib_segments(click_targets.iter().flat_map(|x| x.iter()).map(|x| x.as_ref()), transform);
|
||||
let subtracted = boolean_intersect(path, clip_path).into_iter().flatten().collect::<Vec<_>>();
|
||||
if subtracted.is_empty() {
|
||||
use_children = false;
|
||||
} else {
|
||||
@@ -3083,10 +3141,13 @@ impl<'a> ClickXRayIter<'a> {
|
||||
use_children: !clip || intersects,
|
||||
}
|
||||
}
|
||||
XRayTarget::Quad(quad) => self.check_layer_area_target(click_targets, clip, layer, quad_to_kurbo(*quad), transform),
|
||||
XRayTarget::Quad(quad) => self.check_layer_area_target(click_targets, clip, layer, quad_to_path_lib_segments(*quad), transform),
|
||||
XRayTarget::Path(path) => self.check_layer_area_target(click_targets, clip, layer, path.clone(), transform),
|
||||
XRayTarget::Polygon(polygon) => {
|
||||
let polygon = BezPath::from_path_segments(polygon.iter_closed());
|
||||
let polygon = polygon
|
||||
.iter_closed()
|
||||
.map(|line| path_bool_lib::PathSegment::Line(point_to_dvec2(line.start()), point_to_dvec2(line.end())))
|
||||
.collect();
|
||||
self.check_layer_area_target(click_targets, clip, layer, polygon, transform)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ pub enum GraphOperationMessage {
|
||||
},
|
||||
NewBooleanOperationLayer {
|
||||
id: NodeId,
|
||||
operation: graphene_std::vector::misc::BooleanOperation,
|
||||
operation: graphene_std::path_bool::BooleanOperation,
|
||||
parent: LayerNodeIdentifier,
|
||||
insert_index: usize,
|
||||
},
|
||||
|
||||
@@ -142,7 +142,7 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
LayerNodeIdentifier::new(new_id, self.network_interface)
|
||||
}
|
||||
|
||||
pub fn insert_boolean_data(&mut self, operation: graphene_std::vector::misc::BooleanOperation, layer: LayerNodeIdentifier) {
|
||||
pub fn insert_boolean_data(&mut self, operation: graphene_std::path_bool::BooleanOperation, layer: LayerNodeIdentifier) {
|
||||
let boolean = resolve_network_node_type("Boolean Operation").expect("Boolean node does not exist").node_template_input_override([
|
||||
Some(NodeInput::value(TaggedValue::Graphic(Default::default()), true)),
|
||||
Some(NodeInput::value(TaggedValue::BooleanOperation(operation), false)),
|
||||
@@ -201,8 +201,8 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
Some(NodeInput::value(TaggedValue::F64(typesetting.character_spacing), false)),
|
||||
Some(NodeInput::value(TaggedValue::Bool(typesetting.max_width.is_some()), false)),
|
||||
Some(NodeInput::value(TaggedValue::F64(typesetting.max_width.unwrap_or(100.)), false)),
|
||||
Some(NodeInput::value(TaggedValue::Bool(typesetting.max_height.is_some()), false)),
|
||||
Some(NodeInput::value(TaggedValue::F64(typesetting.max_height.unwrap_or(100.)), false)),
|
||||
Some(NodeInput::value(TaggedValue::Bool(typesetting.max_width.is_some()), false)),
|
||||
Some(NodeInput::value(TaggedValue::F64(typesetting.max_width.unwrap_or(100.)), false)),
|
||||
Some(NodeInput::value(TaggedValue::F64(typesetting.tilt), false)),
|
||||
Some(NodeInput::value(TaggedValue::TextAlign(typesetting.align), false)),
|
||||
]);
|
||||
|
||||
@@ -57,8 +57,7 @@ impl NodePropertiesContext<'_> {
|
||||
/// The key used to access definitions for a network node or proto node.
|
||||
/// For proto nodes, this is their [`ProtoNodeIdentifier`].
|
||||
/// For network nodes, it doesn't necessarily have to be the same as the network's display name, but it often is.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Hash, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Hash, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
#[serde(tag = "type", content = "data")]
|
||||
pub enum DefinitionIdentifier {
|
||||
ProtoNode(ProtoNodeIdentifier),
|
||||
@@ -174,7 +173,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
properties: Some("monitor_properties"),
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Custom Node",
|
||||
identifier: "Default Network",
|
||||
category: "General",
|
||||
node_template: NodeTemplate {
|
||||
document_node: DocumentNode {
|
||||
@@ -1783,7 +1782,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
nodes: vec![
|
||||
DocumentNode {
|
||||
inputs: vec![NodeInput::import(concrete!(Table<Vector>), 0), NodeInput::import(concrete!(vector::style::Fill), 1)],
|
||||
implementation: DocumentNodeImplementation::ProtoNode(path_bool_nodes::boolean_operation::IDENTIFIER),
|
||||
implementation: DocumentNodeImplementation::ProtoNode(path_bool::boolean_operation::IDENTIFIER),
|
||||
call_argument: generic!(T),
|
||||
..Default::default()
|
||||
},
|
||||
@@ -1802,7 +1801,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
}),
|
||||
inputs: vec![
|
||||
NodeInput::value(TaggedValue::Graphic(Default::default()), true),
|
||||
NodeInput::value(TaggedValue::BooleanOperation(vector::misc::BooleanOperation::Union), false),
|
||||
NodeInput::value(TaggedValue::BooleanOperation(path_bool::BooleanOperation::Union), false),
|
||||
],
|
||||
..Default::default()
|
||||
},
|
||||
@@ -2192,10 +2191,9 @@ fn static_input_properties() -> InputProperties {
|
||||
true
|
||||
});
|
||||
|
||||
Ok(vec![LayoutGroup::row(node_properties::number_widget(
|
||||
ParameterWidgetsInfo::new(node_id, index, blank_assist, context),
|
||||
number_input,
|
||||
))])
|
||||
Ok(vec![LayoutGroup::Row {
|
||||
widgets: node_properties::number_widget(ParameterWidgetsInfo::new(node_id, index, blank_assist, context), number_input),
|
||||
}])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
@@ -2229,12 +2227,10 @@ fn static_input_properties() -> InputProperties {
|
||||
number_input = number_input.step(number_step);
|
||||
}
|
||||
};
|
||||
// NOTE: The bool input MUST be at the input index directly before the f64 input!
|
||||
Ok(vec![LayoutGroup::row(node_properties::optional_f64_widget(
|
||||
ParameterWidgetsInfo::new(node_id, index, false, context),
|
||||
index - 1,
|
||||
number_input,
|
||||
))])
|
||||
Ok(vec![LayoutGroup::Row {
|
||||
// NOTE: The bool input MUST be at the input index directly before the f64 input!
|
||||
widgets: node_properties::optional_f64_widget(ParameterWidgetsInfo::new(node_id, index, false, context), index - 1, number_input),
|
||||
}])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
@@ -2302,7 +2298,7 @@ fn static_input_properties() -> InputProperties {
|
||||
"noise_properties_noise_type".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let noise_type_row = enum_choice::<NoiseType>().for_socket(ParameterWidgetsInfo::new(node_id, index, true, context)).property_row();
|
||||
Ok(vec![noise_type_row, LayoutGroup::row(Vec::new())])
|
||||
Ok(vec![noise_type_row, LayoutGroup::Row { widgets: Vec::new() }])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
@@ -2324,7 +2320,7 @@ fn static_input_properties() -> InputProperties {
|
||||
ParameterWidgetsInfo::new(node_id, index, true, context),
|
||||
NumberInput::default().min(0.).disabled(!coherent_noise_active || !domain_warp_active),
|
||||
);
|
||||
Ok(vec![domain_warp_amplitude.into(), LayoutGroup::row(Vec::new())])
|
||||
Ok(vec![domain_warp_amplitude.into(), LayoutGroup::Row { widgets: Vec::new() }])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
@@ -2412,7 +2408,7 @@ fn static_input_properties() -> InputProperties {
|
||||
.range_max(Some(10.))
|
||||
.disabled(!ping_pong_active || !coherent_noise_active || !fractal_active || domain_warp_only_fractal_type_wrongly_active),
|
||||
);
|
||||
Ok(vec![fractal_ping_pong_strength.into(), LayoutGroup::row(Vec::new())])
|
||||
Ok(vec![fractal_ping_pong_strength.into(), LayoutGroup::Row { widgets: Vec::new() }])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
@@ -2508,7 +2504,7 @@ fn static_input_properties() -> InputProperties {
|
||||
]);
|
||||
}
|
||||
|
||||
Ok(vec![LayoutGroup::row(widgets)])
|
||||
Ok(vec![LayoutGroup::Row { widgets }])
|
||||
}),
|
||||
);
|
||||
// Skew has a custom override that maps to degrees
|
||||
@@ -2552,20 +2548,24 @@ fn static_input_properties() -> InputProperties {
|
||||
]);
|
||||
}
|
||||
|
||||
Ok(vec![LayoutGroup::row(widgets)])
|
||||
Ok(vec![LayoutGroup::Row { widgets }])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"text_area".to_string(),
|
||||
Box::new(|node_id, index, context| Ok(vec![LayoutGroup::row(node_properties::text_area_widget(ParameterWidgetsInfo::new(node_id, index, true, context)))])),
|
||||
Box::new(|node_id, index, context| {
|
||||
Ok(vec![LayoutGroup::Row {
|
||||
widgets: node_properties::text_area_widget(ParameterWidgetsInfo::new(node_id, index, true, context)),
|
||||
}])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"text_font".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (font, style) = node_properties::font_inputs(ParameterWidgetsInfo::new(node_id, index, true, context));
|
||||
let mut result = vec![LayoutGroup::row(font)];
|
||||
let mut result = vec![LayoutGroup::Row { widgets: font }];
|
||||
if let Some(style) = style {
|
||||
result.push(LayoutGroup::row(style));
|
||||
result.push(LayoutGroup::Row { widgets: style });
|
||||
}
|
||||
Ok(result)
|
||||
}),
|
||||
|
||||
@@ -645,7 +645,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
||||
|
||||
// Use the network interface to add a default node, then set the imports, exports, paste the nodes inside, and connect them to the imports/exports
|
||||
let encapsulating_node_id = NodeId::new();
|
||||
let mut default_node_template = resolve_network_node_type("Custom Node").expect("Custom Node should exist").default_node_template();
|
||||
let mut default_node_template = resolve_network_node_type("Default Network").expect("Default Network node should exist").default_node_template();
|
||||
let Some(center_of_selected_nodes) = network_interface.selected_nodes_bounding_box(breadcrumb_network_path).map(|[a, b]| (a + b) / 2.) else {
|
||||
log::error!("Could not get center of selected_nodes");
|
||||
return;
|
||||
@@ -847,7 +847,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
||||
};
|
||||
|
||||
self.context_menu = Some(ContextMenuInformation {
|
||||
context_menu_coordinates: (node_graph_point + node_graph_shift).as_ivec2().into(),
|
||||
context_menu_coordinates: (node_graph_point + node_graph_shift).as_ivec2(),
|
||||
context_menu_data,
|
||||
});
|
||||
|
||||
@@ -1280,7 +1280,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
||||
let compatible_type = network_interface.output_type(&output_connector, selection_network_path).add_node_string();
|
||||
|
||||
self.context_menu = Some(ContextMenuInformation {
|
||||
context_menu_coordinates: (point + node_graph_shift).as_ivec2().into(),
|
||||
context_menu_coordinates: (point + node_graph_shift).as_ivec2(),
|
||||
context_menu_data: ContextMenuData::CreateNode { compatible_type },
|
||||
});
|
||||
|
||||
@@ -1521,9 +1521,10 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
||||
for input_index in 0..network_interface.number_of_inputs(selected_node, selection_network_path) {
|
||||
let input_connector = InputConnector::node(*selected_node, input_index);
|
||||
// Only disconnect inputs to non selected nodes
|
||||
if network_interface
|
||||
if !network_interface
|
||||
.upstream_output_connector(&input_connector, selection_network_path)
|
||||
.is_some_and(|connector| connector.node_id().map_or(true, |node_id| !all_selected_nodes.contains(&node_id)))
|
||||
.and_then(|connector| connector.node_id())
|
||||
.is_some_and(|node_id| all_selected_nodes.contains(&node_id))
|
||||
{
|
||||
responses.add(NodeGraphMessage::DisconnectInput { input_connector });
|
||||
}
|
||||
@@ -1948,6 +1949,15 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
||||
}
|
||||
NodeGraphMessage::UpdateBoxSelection => {
|
||||
if let Some((box_selection_start, _)) = self.box_selection_start {
|
||||
// The mouse button was released but we missed the pointer up event
|
||||
// if ((e.buttons & 1) === 0) {
|
||||
// completeBoxSelection();
|
||||
// boxSelection = undefined;
|
||||
// } else if ((e.buttons & 2) !== 0) {
|
||||
// editor.handle.selectNodes(new BigUint64Array(previousSelection));
|
||||
// boxSelection = undefined;
|
||||
// }
|
||||
|
||||
let Some(network_metadata) = network_interface.network_metadata(selection_network_path) else {
|
||||
log::error!("Could not get network metadata in UpdateBoxSelection");
|
||||
return;
|
||||
@@ -2040,8 +2050,8 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
||||
responses.add(FrontendMessage::UpdateImportsExports {
|
||||
imports,
|
||||
exports,
|
||||
import_position: import_position.into(),
|
||||
export_position: export_position.into(),
|
||||
import_position,
|
||||
export_position,
|
||||
add_import_export,
|
||||
});
|
||||
}
|
||||
@@ -2171,7 +2181,7 @@ impl NodeGraphMessageHandler {
|
||||
|
||||
let mut widgets = vec![
|
||||
PopoverButton::new()
|
||||
.icon("Node")
|
||||
.icon(Some("Node".to_string()))
|
||||
.tooltip_label("New Node")
|
||||
.tooltip_description("To add a node at the pointer location, perform the shortcut in an open area of the graph.")
|
||||
.tooltip_shortcut(action_shortcut_manual!(Key::MouseRight))
|
||||
@@ -2212,7 +2222,7 @@ impl NodeGraphMessageHandler {
|
||||
}
|
||||
})
|
||||
.widget_instance();
|
||||
Layout(vec![LayoutGroup::row(vec![node_chooser])])
|
||||
Layout(vec![LayoutGroup::Row { widgets: vec![node_chooser] }])
|
||||
})
|
||||
.widget_instance(),
|
||||
//
|
||||
@@ -2242,14 +2252,14 @@ impl NodeGraphMessageHandler {
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
//
|
||||
IconButton::new(if selection_all_locked { "PadlockLocked" } else { "PadlockUnlocked" }, 24)
|
||||
.hover_icon(if selection_all_locked { "PadlockUnlocked" } else { "PadlockLocked" })
|
||||
.hover_icon(Some((if selection_all_locked { "PadlockUnlocked" } else { "PadlockLocked" }).into()))
|
||||
.tooltip_label(if selection_all_locked { "Unlock Selected" } else { "Lock Selected" })
|
||||
.tooltip_shortcut(action_shortcut!(NodeGraphMessageDiscriminant::ToggleSelectedLocked))
|
||||
.on_update(|_| NodeGraphMessage::ToggleSelectedLocked.into())
|
||||
.disabled(!has_selection || !selection_includes_layers)
|
||||
.widget_instance(),
|
||||
IconButton::new(if selection_all_visible { "EyeVisible" } else { "EyeHidden" }, 24)
|
||||
.hover_icon(if selection_all_visible { "EyeHide" } else { "EyeShow" })
|
||||
.hover_icon(Some((if selection_all_visible { "EyeHide" } else { "EyeShow" }).into()))
|
||||
.tooltip_label(if selection_all_visible { "Hide Selected" } else { "Show Selected" })
|
||||
.tooltip_shortcut(action_shortcut!(NodeGraphMessageDiscriminant::ToggleSelectedVisibility))
|
||||
.on_update(|_| NodeGraphMessage::ToggleSelectedVisibility.into())
|
||||
@@ -2276,7 +2286,7 @@ impl NodeGraphMessageHandler {
|
||||
// If only one node is selected then show the preview or stop previewing button
|
||||
if let Some(node_id) = previewing {
|
||||
let button = TextButton::new("End Preview")
|
||||
.icon("FrameAll")
|
||||
.icon(Some("FrameAll".to_string()))
|
||||
.tooltip_description("Restore preview to the graph output.")
|
||||
.on_update(move |_| NodeGraphMessage::TogglePreview { node_id }.into())
|
||||
.widget_instance();
|
||||
@@ -2288,7 +2298,7 @@ impl NodeGraphMessageHandler {
|
||||
.any(|export| matches!(export, NodeInput::Node { node_id: export_node_id, .. } if *export_node_id == node_id));
|
||||
if selection_is_not_already_the_output && no_other_selections {
|
||||
let button = TextButton::new("Preview")
|
||||
.icon("FrameAll")
|
||||
.icon(Some("FrameAll".to_string()))
|
||||
.tooltip_label("Preview")
|
||||
.tooltip_description("Temporarily set the graph output to the selected node or layer. Perform the shortcut on a node or layer for quick access.")
|
||||
.tooltip_shortcut(action_shortcut_manual!(Key::Alt, Key::MouseLeft))
|
||||
@@ -2313,7 +2323,7 @@ impl NodeGraphMessageHandler {
|
||||
]);
|
||||
}
|
||||
|
||||
self.widgets[0] = LayoutGroup::row(widgets);
|
||||
self.widgets[0] = LayoutGroup::Row { widgets };
|
||||
}
|
||||
|
||||
fn update_graph_bar_right(
|
||||
@@ -2347,15 +2357,15 @@ impl NodeGraphMessageHandler {
|
||||
widgets.extend([
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
TextButton::new("Node Graph")
|
||||
.icon("GraphViewOpen")
|
||||
.hover_icon("GraphViewClosed")
|
||||
.icon(Some("GraphViewOpen".into()))
|
||||
.hover_icon(Some("GraphViewClosed".into()))
|
||||
.tooltip_label("Hide Node Graph")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::GraphViewOverlayToggle))
|
||||
.on_update(move |_| DocumentMessage::GraphViewOverlayToggle.into())
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
||||
self.widgets[1] = LayoutGroup::row(widgets);
|
||||
self.widgets[1] = LayoutGroup::Row { widgets };
|
||||
}
|
||||
|
||||
/// Collate the properties panel sections for a node graph
|
||||
@@ -2397,23 +2407,25 @@ impl NodeGraphMessageHandler {
|
||||
let mut properties = Vec::new();
|
||||
|
||||
if let [node_id] = *nodes.as_slice() {
|
||||
properties.push(LayoutGroup::row(vec![
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextInput::new(context.network_interface.display_name(&node_id, context.selection_network_path))
|
||||
.tooltip_description("Name of the selected node.")
|
||||
.on_update(move |text_input| {
|
||||
NodeGraphMessage::SetDisplayName {
|
||||
node_id,
|
||||
alias: text_input.value.clone(),
|
||||
skip_adding_history_step: false,
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
]));
|
||||
properties.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextInput::new(context.network_interface.display_name(&node_id, context.selection_network_path))
|
||||
.tooltip_description("Name of the selected node.")
|
||||
.on_update(move |text_input| {
|
||||
NodeGraphMessage::SetDisplayName {
|
||||
node_id,
|
||||
alias: text_input.value.clone(),
|
||||
skip_adding_history_step: false,
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
properties.extend(selected_nodes);
|
||||
@@ -2423,16 +2435,18 @@ impl NodeGraphMessageHandler {
|
||||
|
||||
// TODO: Display properties for encapsulating node when no nodes are selected in a nested network
|
||||
// This may require store a separate path for the properties panel
|
||||
let mut properties = vec![LayoutGroup::row(vec![
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
IconLabel::new("File").tooltip_description("Name of the current document.").widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextInput::new(context.document_name)
|
||||
.tooltip_description("Name of the current document.")
|
||||
.on_update(|text_input| DocumentMessage::RenameDocument { new_name: text_input.value.clone() }.into())
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
])];
|
||||
let mut properties = vec![LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
IconLabel::new("File").tooltip_description("Name of the current document.").widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextInput::new(context.document_name)
|
||||
.tooltip_description("Name of the current document.")
|
||||
.on_update(|text_input| DocumentMessage::RenameDocument { new_name: text_input.value.clone() }.into())
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
],
|
||||
}];
|
||||
|
||||
let Some(network) = context.network_interface.nested_network(context.selection_network_path) else {
|
||||
warn!("No network in collate_properties");
|
||||
@@ -2468,48 +2482,50 @@ impl NodeGraphMessageHandler {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let mut layer_properties = vec![LayoutGroup::row(vec![
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextInput::new(context.network_interface.display_name(&layer, context.selection_network_path))
|
||||
.tooltip_description("Name of the selected layer.")
|
||||
.on_update(move |text_input| {
|
||||
NodeGraphMessage::SetDisplayName {
|
||||
node_id: layer,
|
||||
alias: text_input.value.clone(),
|
||||
skip_adding_history_step: false,
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
PopoverButton::new()
|
||||
.icon("Node")
|
||||
.tooltip_description("Add an operation to the end of this layer's chain of nodes.")
|
||||
.popover_layout({
|
||||
let compatible_type = context
|
||||
.network_interface
|
||||
.upstream_output_connector(&InputConnector::node(layer, 1), &[])
|
||||
.and_then(|upstream_output| context.network_interface.output_type(&upstream_output, &[]).add_node_string());
|
||||
let mut layer_properties = vec![LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextInput::new(context.network_interface.display_name(&layer, context.selection_network_path))
|
||||
.tooltip_description("Name of the selected layer.")
|
||||
.on_update(move |text_input| {
|
||||
NodeGraphMessage::SetDisplayName {
|
||||
node_id: layer,
|
||||
alias: text_input.value.clone(),
|
||||
skip_adding_history_step: false,
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
PopoverButton::new()
|
||||
.icon(Some("Node".to_string()))
|
||||
.tooltip_description("Add an operation to the end of this layer's chain of nodes.")
|
||||
.popover_layout({
|
||||
let compatible_type = context
|
||||
.network_interface
|
||||
.upstream_output_connector(&InputConnector::node(layer, 1), &[])
|
||||
.and_then(|upstream_output| context.network_interface.output_type(&upstream_output, &[]).add_node_string());
|
||||
|
||||
let mut node_chooser = NodeCatalog::new();
|
||||
node_chooser.intial_search = compatible_type.unwrap_or("".to_string());
|
||||
let mut node_chooser = NodeCatalog::new();
|
||||
node_chooser.intial_search = compatible_type.unwrap_or("".to_string());
|
||||
|
||||
let node_chooser = node_chooser
|
||||
.on_update(move |node_type| {
|
||||
NodeGraphMessage::CreateNodeInLayerWithTransaction {
|
||||
node_type: node_type.clone(),
|
||||
layer: LayerNodeIdentifier::new_unchecked(layer),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance();
|
||||
Layout(vec![LayoutGroup::row(vec![node_chooser])])
|
||||
})
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
])];
|
||||
let node_chooser = node_chooser
|
||||
.on_update(move |node_type| {
|
||||
NodeGraphMessage::CreateNodeInLayerWithTransaction {
|
||||
node_type: node_type.clone(),
|
||||
layer: LayerNodeIdentifier::new_unchecked(layer),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance();
|
||||
Layout(vec![LayoutGroup::Row { widgets: vec![node_chooser] }])
|
||||
})
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
],
|
||||
}];
|
||||
|
||||
// Iterate through all the upstream nodes, but stop when we reach another layer (since that's a point where we switch from horizontal to vertical flow)
|
||||
let node_properties = context
|
||||
@@ -2635,7 +2651,7 @@ impl NodeGraphMessageHandler {
|
||||
exposed_outputs,
|
||||
primary_output_connected_to_layer,
|
||||
primary_input_connected_to_layer,
|
||||
position: position.into(),
|
||||
position,
|
||||
previewed,
|
||||
visible,
|
||||
locked,
|
||||
@@ -2679,7 +2695,6 @@ impl NodeGraphMessageHandler {
|
||||
if network_interface.is_layer(&error_node, breadcrumb_network_path) {
|
||||
position += IVec2::new(12, -12)
|
||||
}
|
||||
let position = position.into();
|
||||
|
||||
Some(NodeGraphErrorDiagnostic { position, error })
|
||||
}
|
||||
@@ -2826,7 +2841,7 @@ impl Default for NodeGraphMessageHandler {
|
||||
Self {
|
||||
network: Vec::new(),
|
||||
has_selection: false,
|
||||
widgets: [LayoutGroup::row(Vec::new()), LayoutGroup::row(Vec::new())],
|
||||
widgets: [LayoutGroup::Row { widgets: Vec::new() }, LayoutGroup::Row { widgets: Vec::new() }],
|
||||
drag_start: None,
|
||||
begin_dragging: false,
|
||||
node_has_moved_in_drag: false,
|
||||
|
||||
@@ -16,6 +16,7 @@ use graph_craft::{Type, concrete};
|
||||
use graphene_std::NodeInputDecleration;
|
||||
use graphene_std::animation::RealTimeMode;
|
||||
use graphene_std::extract_xy::XY;
|
||||
use graphene_std::path_bool::BooleanOperation;
|
||||
use graphene_std::raster::curve::Curve;
|
||||
use graphene_std::raster::{
|
||||
BlendMode, CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, LuminanceCalculation, NoiseType, RedGreenBlue, RedGreenBlueAlpha, RelativeAbsolute,
|
||||
@@ -25,13 +26,12 @@ use graphene_std::table::{Table, TableRow};
|
||||
use graphene_std::text::{Font, TextAlign};
|
||||
use graphene_std::transform::{Footprint, ReferencePoint, Transform};
|
||||
use graphene_std::vector::QRCodeErrorCorrectionLevel;
|
||||
use graphene_std::vector::misc::BooleanOperation;
|
||||
use graphene_std::vector::misc::{ArcType, CentroidType, ExtrudeJoiningAlgorithm, GridType, MergeByDistanceAlgorithm, PointSpacingType, RowsOrColumns, SpiralType};
|
||||
use graphene_std::vector::style::{Fill, FillChoice, FillType, GradientStops, GradientType, PaintOrder, StrokeAlign, StrokeCap, StrokeJoin};
|
||||
|
||||
pub(crate) fn string_properties(text: &str) -> Vec<LayoutGroup> {
|
||||
let widget = TextLabel::new(text).widget_instance();
|
||||
vec![LayoutGroup::row(vec![widget])]
|
||||
vec![LayoutGroup::Row { widgets: vec![widget] }]
|
||||
}
|
||||
|
||||
fn optionally_update_value<T>(value: impl Fn(&T) -> Option<TaggedValue> + 'static + Send + Sync, node_id: NodeId, input_index: usize) -> impl Fn(&T) -> Message + 'static + Send + Sync {
|
||||
@@ -538,7 +538,11 @@ pub fn footprint_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
||||
);
|
||||
}
|
||||
|
||||
let widgets = [LayoutGroup::row(location_widgets), LayoutGroup::row(scale_widgets), LayoutGroup::row(resolution_widgets)];
|
||||
let widgets = [
|
||||
LayoutGroup::Row { widgets: location_widgets },
|
||||
LayoutGroup::Row { widgets: scale_widgets },
|
||||
LayoutGroup::Row { widgets: resolution_widgets },
|
||||
];
|
||||
let (last, rest) = widgets.split_last().expect("Footprint widget should return multiple rows");
|
||||
*extra_widgets = rest.to_vec();
|
||||
last.clone()
|
||||
@@ -647,9 +651,13 @@ pub fn transform_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
||||
.widget_instance(),
|
||||
]);
|
||||
|
||||
vec![LayoutGroup::row(location_widgets), LayoutGroup::row(rotation_widgets), LayoutGroup::row(scale_widgets)]
|
||||
vec![
|
||||
LayoutGroup::Row { widgets: location_widgets },
|
||||
LayoutGroup::Row { widgets: rotation_widgets },
|
||||
LayoutGroup::Row { widgets: scale_widgets },
|
||||
]
|
||||
} else {
|
||||
vec![LayoutGroup::row(location_widgets)]
|
||||
vec![LayoutGroup::Row { widgets: location_widgets }]
|
||||
};
|
||||
|
||||
if let Some((last, rest)) = widgets.split_last() {
|
||||
@@ -668,7 +676,7 @@ pub fn vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &st
|
||||
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
||||
let Some(input) = document_node.inputs.get(index) else {
|
||||
log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||
return LayoutGroup::row(vec![]);
|
||||
return LayoutGroup::Row { widgets: vec![] };
|
||||
};
|
||||
match input.as_non_exposed_value() {
|
||||
Some(&TaggedValue::DVec2(dvec2)) => {
|
||||
@@ -722,7 +730,7 @@ pub fn vec2_widget(parameter_widgets_info: ParameterWidgetsInfo, x: &str, y: &st
|
||||
_ => {}
|
||||
}
|
||||
|
||||
LayoutGroup::row(widgets)
|
||||
LayoutGroup::Row { widgets }
|
||||
}
|
||||
|
||||
pub fn array_of_number_widget(parameter_widgets_info: ParameterWidgetsInfo, text_input: TextInput) -> Vec<WidgetInstance> {
|
||||
@@ -1093,7 +1101,7 @@ pub fn blend_mode_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Layout
|
||||
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
||||
let Some(input) = document_node.inputs.get(index) else {
|
||||
log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||
return LayoutGroup::row(vec![]);
|
||||
return LayoutGroup::Row { widgets: vec![] };
|
||||
};
|
||||
if let Some(&TaggedValue::BlendMode(blend_mode)) = input.as_non_exposed_value() {
|
||||
let entries = BlendMode::list_svg_subset()
|
||||
@@ -1118,7 +1126,7 @@ pub fn blend_mode_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Layout
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
LayoutGroup::row(widgets).with_tooltip_description("Formula used for blending.")
|
||||
LayoutGroup::Row { widgets }.with_tooltip_description("Formula used for blending.")
|
||||
}
|
||||
|
||||
pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button: ColorInput) -> LayoutGroup {
|
||||
@@ -1129,7 +1137,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
||||
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
||||
// Return early with just the label if the input is exposed to the graph, meaning we don't want to show the color picker widget in the Properties panel
|
||||
let NodeInput::Value { tagged_value, exposed: false } = &document_node.inputs[index] else {
|
||||
return LayoutGroup::row(widgets);
|
||||
return LayoutGroup::Row { widgets };
|
||||
};
|
||||
|
||||
// Add a separator
|
||||
@@ -1168,7 +1176,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
||||
x => warn!("Color {x:?}"),
|
||||
}
|
||||
|
||||
LayoutGroup::row(widgets)
|
||||
LayoutGroup::Row { widgets }
|
||||
}
|
||||
|
||||
pub fn font_widget(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup {
|
||||
@@ -1184,7 +1192,7 @@ pub fn curve_widget(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup
|
||||
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
||||
let Some(input) = document_node.inputs.get(index) else {
|
||||
log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||
return LayoutGroup::row(vec![]);
|
||||
return LayoutGroup::Row { widgets: vec![] };
|
||||
};
|
||||
if let Some(TaggedValue::Curve(curve)) = &input.as_non_exposed_value() {
|
||||
widgets.extend_from_slice(&[
|
||||
@@ -1195,7 +1203,7 @@ pub fn curve_widget(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup
|
||||
.widget_instance(),
|
||||
])
|
||||
}
|
||||
LayoutGroup::row(widgets)
|
||||
LayoutGroup::Row { widgets }
|
||||
}
|
||||
|
||||
pub fn get_document_node<'a>(node_id: NodeId, context: &'a NodePropertiesContext<'a>) -> Result<&'a DocumentNode, String> {
|
||||
@@ -1298,10 +1306,10 @@ pub(crate) fn brightness_contrast_properties(node_id: NodeId, context: &mut Node
|
||||
.range_max(Some(100.)),
|
||||
);
|
||||
|
||||
let mut layout = vec![LayoutGroup::row(brightness), LayoutGroup::row(contrast)];
|
||||
let mut layout = vec![LayoutGroup::Row { widgets: brightness }, LayoutGroup::Row { widgets: contrast }];
|
||||
if includes_use_classic {
|
||||
// TODO: When we no longer use this function in the temporary "Brightness/Contrast Classic" node, remove this conditional pushing and just always include this
|
||||
layout.push(LayoutGroup::row(use_classic));
|
||||
layout.push(LayoutGroup::Row { widgets: use_classic });
|
||||
}
|
||||
|
||||
layout
|
||||
@@ -1350,13 +1358,18 @@ pub(crate) fn channel_mixer_properties(node_id: NodeId, context: &mut NodeProper
|
||||
let constant = number_widget(ParameterWidgetsInfo::new(node_id, constant_output_index, true, context), number_input);
|
||||
|
||||
// Monochrome
|
||||
let mut layout = vec![LayoutGroup::row(is_monochrome)];
|
||||
let mut layout = vec![LayoutGroup::Row { widgets: is_monochrome }];
|
||||
// Output channel choice
|
||||
if !is_monochrome_value {
|
||||
layout.push(output_channel);
|
||||
}
|
||||
// Channel values
|
||||
layout.extend([LayoutGroup::row(red), LayoutGroup::row(green), LayoutGroup::row(blue), LayoutGroup::row(constant)]);
|
||||
layout.extend([
|
||||
LayoutGroup::Row { widgets: red },
|
||||
LayoutGroup::Row { widgets: green },
|
||||
LayoutGroup::Row { widgets: blue },
|
||||
LayoutGroup::Row { widgets: constant },
|
||||
]);
|
||||
layout
|
||||
}
|
||||
|
||||
@@ -1409,10 +1422,10 @@ pub(crate) fn selective_color_properties(node_id: NodeId, context: &mut NodeProp
|
||||
// Colors choice
|
||||
colors,
|
||||
// CMYK
|
||||
LayoutGroup::row(cyan),
|
||||
LayoutGroup::row(magenta),
|
||||
LayoutGroup::row(yellow),
|
||||
LayoutGroup::row(black),
|
||||
LayoutGroup::Row { widgets: cyan },
|
||||
LayoutGroup::Row { widgets: magenta },
|
||||
LayoutGroup::Row { widgets: yellow },
|
||||
LayoutGroup::Row { widgets: black },
|
||||
// Mode
|
||||
mode,
|
||||
]
|
||||
@@ -1445,10 +1458,12 @@ pub(crate) fn grid_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
||||
widgets.push(spacing);
|
||||
}
|
||||
GridType::Isometric => {
|
||||
let spacing = LayoutGroup::row(number_widget(
|
||||
ParameterWidgetsInfo::new(node_id, SpacingInput::<f64>::INDEX, true, context),
|
||||
NumberInput::default().label("H").min(0.).unit(" px"),
|
||||
));
|
||||
let spacing = LayoutGroup::Row {
|
||||
widgets: number_widget(
|
||||
ParameterWidgetsInfo::new(node_id, SpacingInput::<f64>::INDEX, true, context),
|
||||
NumberInput::default().label("H").min(0.).unit(" px"),
|
||||
),
|
||||
};
|
||||
let angles = vec2_widget(ParameterWidgetsInfo::new(node_id, AnglesInput::INDEX, true, context), "", "", "°", None, false);
|
||||
widgets.extend([spacing, angles]);
|
||||
}
|
||||
@@ -1458,7 +1473,7 @@ pub(crate) fn grid_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
||||
let columns = number_widget(ParameterWidgetsInfo::new(node_id, ColumnsInput::INDEX, true, context), NumberInput::default().min(1.));
|
||||
let rows = number_widget(ParameterWidgetsInfo::new(node_id, RowsInput::INDEX, true, context), NumberInput::default().min(1.));
|
||||
|
||||
widgets.extend([LayoutGroup::row(columns), LayoutGroup::row(rows)]);
|
||||
widgets.extend([LayoutGroup::Row { widgets: columns }, LayoutGroup::Row { widgets: rows }]);
|
||||
|
||||
widgets
|
||||
}
|
||||
@@ -1472,7 +1487,7 @@ pub(crate) fn spiral_properties(node_id: NodeId, context: &mut NodePropertiesCon
|
||||
let turns = number_widget(ParameterWidgetsInfo::new(node_id, TurnsInput::INDEX, true, context), NumberInput::default().min(0.1));
|
||||
let start_angle = number_widget(ParameterWidgetsInfo::new(node_id, StartAngleInput::INDEX, true, context), NumberInput::default().unit("°"));
|
||||
|
||||
let mut widgets = vec![spiral_type, LayoutGroup::row(turns), LayoutGroup::row(start_angle)];
|
||||
let mut widgets = vec![spiral_type, LayoutGroup::Row { widgets: turns }, LayoutGroup::Row { widgets: start_angle }];
|
||||
|
||||
let document_node = match get_document_node(node_id, context) {
|
||||
Ok(document_node) => document_node,
|
||||
@@ -1489,28 +1504,24 @@ pub(crate) fn spiral_properties(node_id: NodeId, context: &mut NodePropertiesCon
|
||||
if let Some(&TaggedValue::SpiralType(spiral_type)) = spiral_type_input.as_non_exposed_value() {
|
||||
match spiral_type {
|
||||
SpiralType::Archimedean => {
|
||||
let inner_radius = LayoutGroup::row(number_widget(
|
||||
ParameterWidgetsInfo::new(node_id, InnerRadiusInput::INDEX, true, context),
|
||||
NumberInput::default().min(0.).unit(" px"),
|
||||
));
|
||||
let inner_radius = LayoutGroup::Row {
|
||||
widgets: number_widget(ParameterWidgetsInfo::new(node_id, InnerRadiusInput::INDEX, true, context), NumberInput::default().min(0.).unit(" px")),
|
||||
};
|
||||
|
||||
let outer_radius = LayoutGroup::row(number_widget(
|
||||
ParameterWidgetsInfo::new(node_id, OuterRadiusInput::INDEX, true, context),
|
||||
NumberInput::default().unit(" px"),
|
||||
));
|
||||
let outer_radius = LayoutGroup::Row {
|
||||
widgets: number_widget(ParameterWidgetsInfo::new(node_id, OuterRadiusInput::INDEX, true, context), NumberInput::default().unit(" px")),
|
||||
};
|
||||
|
||||
widgets.extend([inner_radius, outer_radius]);
|
||||
}
|
||||
SpiralType::Logarithmic => {
|
||||
let inner_radius = LayoutGroup::row(number_widget(
|
||||
ParameterWidgetsInfo::new(node_id, InnerRadiusInput::INDEX, true, context),
|
||||
NumberInput::default().min(0.).unit(" px"),
|
||||
));
|
||||
let inner_radius = LayoutGroup::Row {
|
||||
widgets: number_widget(ParameterWidgetsInfo::new(node_id, InnerRadiusInput::INDEX, true, context), NumberInput::default().min(0.).unit(" px")),
|
||||
};
|
||||
|
||||
let outer_radius = LayoutGroup::row(number_widget(
|
||||
ParameterWidgetsInfo::new(node_id, OuterRadiusInput::INDEX, true, context),
|
||||
NumberInput::default().min(0.1).unit(" px"),
|
||||
));
|
||||
let outer_radius = LayoutGroup::Row {
|
||||
widgets: number_widget(ParameterWidgetsInfo::new(node_id, OuterRadiusInput::INDEX, true, context), NumberInput::default().min(0.1).unit(" px")),
|
||||
};
|
||||
|
||||
widgets.extend([inner_radius, outer_radius]);
|
||||
}
|
||||
@@ -1522,7 +1533,7 @@ pub(crate) fn spiral_properties(node_id: NodeId, context: &mut NodePropertiesCon
|
||||
NumberInput::default().min(1.).max(180.).unit("°"),
|
||||
);
|
||||
|
||||
widgets.push(LayoutGroup::row(angular_resolution));
|
||||
widgets.push(LayoutGroup::Row { widgets: angular_resolution });
|
||||
|
||||
widgets
|
||||
}
|
||||
@@ -1563,13 +1574,13 @@ pub(crate) fn sample_polyline_properties(node_id: NodeId, context: &mut NodeProp
|
||||
vec![
|
||||
spacing.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_SPACING),
|
||||
match current_spacing {
|
||||
Some(TaggedValue::PointSpacingType(PointSpacingType::Separation)) => LayoutGroup::row(separation).with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_SEPARATION),
|
||||
Some(TaggedValue::PointSpacingType(PointSpacingType::Quantity)) => LayoutGroup::row(quantity).with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_QUANTITY),
|
||||
_ => LayoutGroup::row(vec![]),
|
||||
Some(TaggedValue::PointSpacingType(PointSpacingType::Separation)) => LayoutGroup::Row { widgets: separation }.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_SEPARATION),
|
||||
Some(TaggedValue::PointSpacingType(PointSpacingType::Quantity)) => LayoutGroup::Row { widgets: quantity }.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_QUANTITY),
|
||||
_ => LayoutGroup::Row { widgets: vec![] },
|
||||
},
|
||||
LayoutGroup::row(start_offset).with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_START_OFFSET),
|
||||
LayoutGroup::row(stop_offset).with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_STOP_OFFSET),
|
||||
LayoutGroup::row(adaptive_spacing).with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_ADAPTIVE_SPACING),
|
||||
LayoutGroup::Row { widgets: start_offset }.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_START_OFFSET),
|
||||
LayoutGroup::Row { widgets: stop_offset }.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_STOP_OFFSET),
|
||||
LayoutGroup::Row { widgets: adaptive_spacing }.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_ADAPTIVE_SPACING),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1583,7 +1594,11 @@ pub(crate) fn exposure_properties(node_id: NodeId, context: &mut NodePropertiesC
|
||||
NumberInput::default().min(0.01).max(9.99).increment_step(0.1),
|
||||
);
|
||||
|
||||
vec![LayoutGroup::row(exposure), LayoutGroup::row(offset), LayoutGroup::row(gamma_correction)]
|
||||
vec![
|
||||
LayoutGroup::Row { widgets: exposure },
|
||||
LayoutGroup::Row { widgets: offset },
|
||||
LayoutGroup::Row { widgets: gamma_correction },
|
||||
]
|
||||
}
|
||||
|
||||
pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
@@ -1707,11 +1722,11 @@ pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodeProperties
|
||||
let clamped = bool_widget(ParameterWidgetsInfo::new(node_id, ClampedInput::INDEX, true, context), CheckboxInput::default());
|
||||
|
||||
vec![
|
||||
LayoutGroup::row(size_x),
|
||||
LayoutGroup::row(size_y),
|
||||
LayoutGroup::row(corner_radius_row_1),
|
||||
LayoutGroup::row(corner_radius_row_2),
|
||||
LayoutGroup::row(clamped),
|
||||
LayoutGroup::Row { widgets: size_x },
|
||||
LayoutGroup::Row { widgets: size_y },
|
||||
LayoutGroup::Row { widgets: corner_radius_row_1 },
|
||||
LayoutGroup::Row { widgets: corner_radius_row_2 },
|
||||
LayoutGroup::Row { widgets: clamped },
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1796,21 +1811,7 @@ pub(crate) fn generate_node_properties(node_id: NodeId, context: &mut NodeProper
|
||||
if layout.is_empty() {
|
||||
layout = node_no_properties(node_id, context);
|
||||
}
|
||||
|
||||
let display_name = context
|
||||
.network_interface
|
||||
.node_metadata(&node_id, context.selection_network_path)
|
||||
.map(|metadata| metadata.persistent_metadata.display_name.as_str());
|
||||
let implementation_name = context.network_interface.implementation_name(&node_id, context.selection_network_path);
|
||||
let name = if let Some(display_name) = display_name
|
||||
&& implementation_name != display_name
|
||||
&& implementation_name != "Custom Node"
|
||||
&& !display_name.is_empty()
|
||||
{
|
||||
format!("{display_name} ({implementation_name})")
|
||||
} else {
|
||||
implementation_name
|
||||
};
|
||||
let name = context.network_interface.implementation_name(&node_id, context.selection_network_path);
|
||||
|
||||
let description = context
|
||||
.network_interface
|
||||
@@ -1824,7 +1825,14 @@ pub(crate) fn generate_node_properties(node_id: NodeId, context: &mut NodeProper
|
||||
let visible = context.network_interface.is_visible(&node_id, context.selection_network_path);
|
||||
let pinned = context.network_interface.is_pinned(&node_id, context.selection_network_path);
|
||||
|
||||
LayoutGroup::section(name, description, visible, pinned, node_id.0, Layout(layout))
|
||||
LayoutGroup::Section {
|
||||
name,
|
||||
description,
|
||||
visible,
|
||||
pinned,
|
||||
id: node_id.0,
|
||||
layout: Layout(layout),
|
||||
}
|
||||
}
|
||||
|
||||
/// Fill Node Widgets LayoutGroup
|
||||
@@ -1848,7 +1856,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
||||
) {
|
||||
(fill, backup_color, backup_gradient)
|
||||
} else {
|
||||
return vec![LayoutGroup::row(widgets_first_row)];
|
||||
return vec![LayoutGroup::Row { widgets: widgets_first_row }];
|
||||
};
|
||||
let fill2 = fill.clone();
|
||||
let backup_color_fill: Fill = backup_color.clone().into();
|
||||
@@ -1891,7 +1899,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
||||
.on_commit(commit_value)
|
||||
.widget_instance(),
|
||||
);
|
||||
let mut widgets = vec![LayoutGroup::row(widgets_first_row)];
|
||||
let mut widgets = vec![LayoutGroup::Row { widgets: widgets_first_row }];
|
||||
|
||||
let fill_type_switch = {
|
||||
let mut row = vec![TextLabel::new("").widget_instance()];
|
||||
@@ -1934,7 +1942,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
||||
RadioInput::new(entries).selected_index(Some(if fill.as_gradient().is_some() { 1 } else { 0 })).widget_instance(),
|
||||
]);
|
||||
|
||||
LayoutGroup::row(row)
|
||||
LayoutGroup::Row { widgets: row }
|
||||
};
|
||||
widgets.push(fill_type_switch);
|
||||
|
||||
@@ -2003,7 +2011,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
||||
RadioInput::new(entries).selected_index(Some(gradient.gradient_type as u32)).widget_instance(),
|
||||
]);
|
||||
|
||||
widgets.push(LayoutGroup::row(row));
|
||||
widgets.push(LayoutGroup::Row { widgets: row });
|
||||
}
|
||||
|
||||
widgets
|
||||
@@ -2061,14 +2069,14 @@ pub fn stroke_properties(node_id: NodeId, context: &mut NodePropertiesContext) -
|
||||
|
||||
vec![
|
||||
color,
|
||||
LayoutGroup::row(weight),
|
||||
LayoutGroup::Row { widgets: weight },
|
||||
align,
|
||||
cap,
|
||||
join,
|
||||
LayoutGroup::row(miter_limit),
|
||||
LayoutGroup::Row { widgets: miter_limit },
|
||||
paint_order,
|
||||
LayoutGroup::row(dash_lengths),
|
||||
LayoutGroup::row(dash_offset),
|
||||
LayoutGroup::Row { widgets: dash_lengths },
|
||||
LayoutGroup::Row { widgets: dash_offset },
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2098,7 +2106,7 @@ pub fn offset_path_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
||||
});
|
||||
let miter_limit = number_widget(ParameterWidgetsInfo::new(node_id, MiterLimitInput::INDEX, true, context), number_input);
|
||||
|
||||
vec![LayoutGroup::row(distance), join, LayoutGroup::row(miter_limit)]
|
||||
vec![LayoutGroup::Row { widgets: distance }, join, LayoutGroup::Row { widgets: miter_limit }]
|
||||
}
|
||||
|
||||
pub fn math_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
@@ -2150,9 +2158,9 @@ pub fn math_properties(node_id: NodeId, context: &mut NodePropertiesContext) ->
|
||||
let operand_a_hint = vec![TextLabel::new("(Operand A is the primary input)").widget_instance()];
|
||||
|
||||
vec![
|
||||
LayoutGroup::row(expression).with_tooltip_description(r#"A math expression that may incorporate "A" and/or "B", such as "sqrt(A + B) - B^2"."#),
|
||||
LayoutGroup::row(operand_b).with_tooltip_description(r#"The value of "B" when calculating the expression."#),
|
||||
LayoutGroup::row(operand_a_hint).with_tooltip_description(r#""A" is fed by the value from the previous node in the primary data flow, or it is 0 if disconnected."#),
|
||||
LayoutGroup::Row { widgets: expression }.with_tooltip_description(r#"A math expression that may incorporate "A" and/or "B", such as "sqrt(A + B) - B^2"."#),
|
||||
LayoutGroup::Row { widgets: operand_b }.with_tooltip_description(r#"The value of "B" when calculating the expression."#),
|
||||
LayoutGroup::Row { widgets: operand_a_hint }.with_tooltip_description(r#""A" is fed by the value from the previous node in the primary data flow, or it is 0 if disconnected."#),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2340,14 +2348,14 @@ pub mod choice {
|
||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = self.parameter_info;
|
||||
let Some(document_node) = document_node else {
|
||||
log::error!("Could not get document node when building property row for node {node_id:?}");
|
||||
return LayoutGroup::row(Vec::new());
|
||||
return LayoutGroup::Row { widgets: Vec::new() };
|
||||
};
|
||||
|
||||
let mut widgets = super::start_widgets(self.parameter_info);
|
||||
|
||||
let Some(input) = document_node.inputs.get(index) else {
|
||||
log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||
return LayoutGroup::row(vec![]);
|
||||
return LayoutGroup::Row { widgets: vec![] };
|
||||
};
|
||||
|
||||
let input: Option<W::Value> = input.as_non_exposed_value().and_then(|v| <&W::Value as TryFrom<&TaggedValue>>::try_from(v).ok()).cloned();
|
||||
@@ -2359,7 +2367,7 @@ pub mod choice {
|
||||
widgets.extend_from_slice(&[Separator::new(SeparatorStyle::Unrelated).widget_instance(), widget]);
|
||||
}
|
||||
|
||||
let mut row = LayoutGroup::row(widgets);
|
||||
let mut row = LayoutGroup::Row { widgets };
|
||||
if let Some(desc) = self.widget_factory.description() {
|
||||
row = row.with_tooltip_description(desc);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use glam::IVec2;
|
||||
use graph_craft::document::NodeId;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graphene_std::Type;
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum FrontendGraphDataType {
|
||||
#[default]
|
||||
General,
|
||||
@@ -42,8 +42,7 @@ impl FrontendGraphDataType {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct FrontendGraphInput {
|
||||
#[serde(rename = "dataType")]
|
||||
pub data_type: FrontendGraphDataType,
|
||||
@@ -58,23 +57,21 @@ pub struct FrontendGraphInput {
|
||||
pub connected_to: String,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct FrontendGraphOutput {
|
||||
#[serde(rename = "dataType")]
|
||||
pub data_type: FrontendGraphDataType,
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
#[serde(rename = "resolvedType")]
|
||||
pub resolved_type: String,
|
||||
pub description: String,
|
||||
/// If connected to an export, it is "export index {index}".
|
||||
/// If connected to a node, it is "{node name} input {input_index}".
|
||||
#[serde(rename = "connectedTo")]
|
||||
pub connected_to: Vec<String>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct FrontendNode {
|
||||
pub id: graph_craft::document::NodeId,
|
||||
#[serde(rename = "isLayer")]
|
||||
@@ -98,14 +95,13 @@ pub struct FrontendNode {
|
||||
pub primary_input_connected_to_layer: bool,
|
||||
#[serde(rename = "primaryOutputConnectedToLayer")]
|
||||
pub primary_output_connected_to_layer: bool,
|
||||
pub position: (i32, i32),
|
||||
pub position: IVec2,
|
||||
pub previewed: bool,
|
||||
pub visible: bool,
|
||||
pub locked: bool,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct FrontendNodeType {
|
||||
pub identifier: String,
|
||||
pub name: String,
|
||||
@@ -114,8 +110,7 @@ pub struct FrontendNodeType {
|
||||
pub input_types: Vec<String>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct DragStart {
|
||||
pub start_x: f64,
|
||||
pub start_y: f64,
|
||||
@@ -123,8 +118,14 @@ pub struct DragStart {
|
||||
pub round_y: i32,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct Transform {
|
||||
pub scale: f64,
|
||||
pub x: f64,
|
||||
pub y: f64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct BoxSelection {
|
||||
#[serde(rename = "startX")]
|
||||
pub start_x: u32,
|
||||
@@ -136,8 +137,7 @@ pub struct BoxSelection {
|
||||
pub end_y: u32,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
#[serde(tag = "type", content = "data")]
|
||||
pub enum ContextMenuData {
|
||||
ModifyNode {
|
||||
@@ -158,25 +158,22 @@ pub enum ContextMenuData {
|
||||
},
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct ContextMenuInformation {
|
||||
// Stores whether the context menu is open and its position in graph coordinates
|
||||
#[serde(rename = "contextMenuCoordinates")]
|
||||
pub context_menu_coordinates: (i32, i32),
|
||||
pub context_menu_coordinates: IVec2,
|
||||
#[serde(rename = "contextMenuData")]
|
||||
pub context_menu_data: ContextMenuData,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct NodeGraphErrorDiagnostic {
|
||||
pub position: (i32, i32),
|
||||
pub position: IVec2,
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct FrontendClickTargets {
|
||||
#[serde(rename = "nodeClickTargets")]
|
||||
pub node_click_targets: Vec<String>,
|
||||
@@ -192,8 +189,7 @@ pub struct FrontendClickTargets {
|
||||
pub modify_import_export: Vec<String>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum Direction {
|
||||
Up,
|
||||
Down,
|
||||
|
||||
@@ -228,38 +228,42 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
||||
})
|
||||
};
|
||||
|
||||
widgets.push(LayoutGroup::row(vec![TextLabel::new("Grid").bold(true).widget_instance()]));
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![TextLabel::new("Grid").bold(true).widget_instance()],
|
||||
});
|
||||
|
||||
widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Type").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
RadioInput::new(vec![
|
||||
RadioEntryData::new("rectangular").label("Rectangular").on_update(update_val(grid, |grid, _| {
|
||||
if let GridType::Isometric { y_axis_spacing, angle_a, angle_b } = grid.grid_type {
|
||||
grid.isometric_y_spacing = y_axis_spacing;
|
||||
grid.isometric_angle_a = angle_a;
|
||||
grid.isometric_angle_b = angle_b;
|
||||
}
|
||||
grid.grid_type = GridType::Rectangular { spacing: grid.rectangular_spacing };
|
||||
})),
|
||||
RadioEntryData::new("isometric").label("Isometric").on_update(update_val(grid, |grid, _| {
|
||||
if let GridType::Rectangular { spacing } = grid.grid_type {
|
||||
grid.rectangular_spacing = spacing;
|
||||
}
|
||||
grid.grid_type = GridType::Isometric {
|
||||
y_axis_spacing: grid.isometric_y_spacing,
|
||||
angle_a: grid.isometric_angle_a,
|
||||
angle_b: grid.isometric_angle_b,
|
||||
};
|
||||
})),
|
||||
])
|
||||
.min_width(200)
|
||||
.selected_index(Some(match grid.grid_type {
|
||||
GridType::Rectangular { .. } => 0,
|
||||
GridType::Isometric { .. } => 1,
|
||||
}))
|
||||
.widget_instance(),
|
||||
]));
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Type").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
RadioInput::new(vec![
|
||||
RadioEntryData::new("rectangular").label("Rectangular").on_update(update_val(grid, |grid, _| {
|
||||
if let GridType::Isometric { y_axis_spacing, angle_a, angle_b } = grid.grid_type {
|
||||
grid.isometric_y_spacing = y_axis_spacing;
|
||||
grid.isometric_angle_a = angle_a;
|
||||
grid.isometric_angle_b = angle_b;
|
||||
}
|
||||
grid.grid_type = GridType::Rectangular { spacing: grid.rectangular_spacing };
|
||||
})),
|
||||
RadioEntryData::new("isometric").label("Isometric").on_update(update_val(grid, |grid, _| {
|
||||
if let GridType::Rectangular { spacing } = grid.grid_type {
|
||||
grid.rectangular_spacing = spacing;
|
||||
}
|
||||
grid.grid_type = GridType::Isometric {
|
||||
y_axis_spacing: grid.isometric_y_spacing,
|
||||
angle_a: grid.isometric_angle_a,
|
||||
angle_b: grid.isometric_angle_b,
|
||||
};
|
||||
})),
|
||||
])
|
||||
.min_width(200)
|
||||
.selected_index(Some(match grid.grid_type {
|
||||
GridType::Rectangular { .. } => 0,
|
||||
GridType::Isometric { .. } => 1,
|
||||
}))
|
||||
.widget_instance(),
|
||||
],
|
||||
});
|
||||
|
||||
let mut color_widgets = vec![
|
||||
TextLabel::new("Display").table_align(true).widget_instance(),
|
||||
@@ -284,72 +288,80 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
||||
}))
|
||||
.widget_instance(),
|
||||
);
|
||||
widgets.push(LayoutGroup::row(color_widgets));
|
||||
widgets.push(LayoutGroup::Row { widgets: color_widgets });
|
||||
|
||||
widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Origin").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(grid.origin.x))
|
||||
.label("X")
|
||||
.unit(" px")
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.x)))
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
NumberInput::new(Some(grid.origin.y))
|
||||
.label("Y")
|
||||
.unit(" px")
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.y)))
|
||||
.widget_instance(),
|
||||
]));
|
||||
|
||||
match grid.grid_type {
|
||||
GridType::Rectangular { spacing } => widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Spacing").table_align(true).widget_instance(),
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Origin").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(spacing.x))
|
||||
NumberInput::new(Some(grid.origin.x))
|
||||
.label("X")
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.rectangular_spacing().map(|spacing| &mut spacing.x)))
|
||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.x)))
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
NumberInput::new(Some(spacing.y))
|
||||
NumberInput::new(Some(grid.origin.y))
|
||||
.label("Y")
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.rectangular_spacing().map(|spacing| &mut spacing.y)))
|
||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.y)))
|
||||
.widget_instance(),
|
||||
])),
|
||||
GridType::Isometric { y_axis_spacing, angle_a, angle_b } => {
|
||||
widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Y Spacing").table_align(true).widget_instance(),
|
||||
],
|
||||
});
|
||||
|
||||
match grid.grid_type {
|
||||
GridType::Rectangular { spacing } => widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Spacing").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(y_axis_spacing))
|
||||
NumberInput::new(Some(spacing.x))
|
||||
.label("X")
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(200)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.isometric_y_spacing()))
|
||||
.widget_instance(),
|
||||
]));
|
||||
widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Angles").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(angle_a))
|
||||
.unit("°")
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.angle_a()))
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.rectangular_spacing().map(|spacing| &mut spacing.x)))
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
NumberInput::new(Some(angle_b))
|
||||
.unit("°")
|
||||
NumberInput::new(Some(spacing.y))
|
||||
.label("Y")
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.angle_b()))
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.rectangular_spacing().map(|spacing| &mut spacing.y)))
|
||||
.widget_instance(),
|
||||
]));
|
||||
],
|
||||
}),
|
||||
GridType::Isometric { y_axis_spacing, angle_a, angle_b } => {
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Y Spacing").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(y_axis_spacing))
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(200)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.isometric_y_spacing()))
|
||||
.widget_instance(),
|
||||
],
|
||||
});
|
||||
widgets.push(LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
TextLabel::new("Angles").table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(angle_a))
|
||||
.unit("°")
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.angle_a()))
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
NumberInput::new(Some(angle_b))
|
||||
.unit("°")
|
||||
.min_width(98)
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.angle_b()))
|
||||
.widget_instance(),
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ pub mod grid_overlays;
|
||||
mod overlays_message;
|
||||
mod overlays_message_handler;
|
||||
pub mod utility_functions;
|
||||
// Native (non‑Wasm)
|
||||
// Native (non‑wasm)
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
pub mod utility_types_native;
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
|
||||
@@ -42,8 +42,7 @@ pub enum GizmoEmphasis {
|
||||
|
||||
// TODO Remove duplicated definition of this in `utility_types_web.rs`
|
||||
/// Types of overlays used by DocumentMessage to enable/disable the selected set of viewport overlays.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum OverlaysType {
|
||||
ArtboardName,
|
||||
CompassRose,
|
||||
@@ -61,8 +60,7 @@ pub enum OverlaysType {
|
||||
}
|
||||
|
||||
// TODO Remove duplicated definition of this in `utility_types_web.rs`
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
#[serde(default)]
|
||||
pub struct OverlaysVisibilitySettings {
|
||||
pub all: bool,
|
||||
@@ -162,11 +160,11 @@ impl OverlaysVisibilitySettings {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct OverlayContext {
|
||||
// Serde functionality isn't used but is required by the message system macros
|
||||
#[serde(skip)]
|
||||
#[specta(skip)]
|
||||
internal: Arc<Mutex<OverlayContextInternal>>,
|
||||
pub viewport: ViewportMessageHandler,
|
||||
pub visibility_settings: OverlaysVisibilitySettings,
|
||||
|
||||
@@ -35,8 +35,7 @@ pub enum GizmoEmphasis {
|
||||
}
|
||||
|
||||
/// Types of overlays used by DocumentMessage to enable/disable the selected set of viewport overlays.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum OverlaysType {
|
||||
ArtboardName,
|
||||
CompassRose,
|
||||
@@ -53,8 +52,7 @@ pub enum OverlaysType {
|
||||
Handles,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
#[serde(default)]
|
||||
pub struct OverlaysVisibilitySettings {
|
||||
pub all: bool,
|
||||
@@ -152,11 +150,11 @@ impl OverlaysVisibilitySettings {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct OverlayContext {
|
||||
// Serde functionality isn't used but is required by the message system macros
|
||||
#[serde(skip, default = "overlay_canvas_context")]
|
||||
#[specta(skip)]
|
||||
pub render_context: web_sys::CanvasRenderingContext2d,
|
||||
pub viewport: ViewportMessageHandler,
|
||||
pub visibility_settings: OverlaysVisibilitySettings,
|
||||
|
||||
@@ -2,8 +2,7 @@ use super::network_interface::NodeTemplate;
|
||||
use graph_craft::document::NodeId;
|
||||
|
||||
#[repr(u8)]
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
|
||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, Eq, Debug, specta::Type)]
|
||||
pub enum Clipboard {
|
||||
Internal,
|
||||
Device,
|
||||
|
||||
@@ -234,8 +234,7 @@ impl DocumentMetadata {
|
||||
// ===================
|
||||
|
||||
/// ID of a layer node
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct LayerNodeIdentifier(NonZeroU64);
|
||||
|
||||
impl core::fmt::Debug for LayerNodeIdentifier {
|
||||
|
||||
@@ -3,8 +3,7 @@ use glam::DVec2;
|
||||
use std::fmt;
|
||||
|
||||
#[repr(transparent)]
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct DocumentId(pub u64);
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash)]
|
||||
@@ -13,15 +12,13 @@ pub enum FlipAxis {
|
||||
Y,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash, specta::Type)]
|
||||
pub enum AlignAxis {
|
||||
X,
|
||||
Y,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash)]
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash, specta::Type)]
|
||||
pub enum AlignAggregate {
|
||||
Min,
|
||||
Max,
|
||||
@@ -710,5 +707,5 @@ impl PTZ {
|
||||
#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum GroupFolderType {
|
||||
Layer,
|
||||
BooleanOperation(graphene_std::vector::misc::BooleanOperation),
|
||||
BooleanOperation(graphene_std::path_bool::BooleanOperation),
|
||||
}
|
||||
@@ -4068,8 +4068,8 @@ impl NodeNetworkInterface {
|
||||
log::error!("Could not get current input in disconnect_input");
|
||||
return;
|
||||
};
|
||||
// Only disconnect inputs that are actual wire connections (Node or Import)
|
||||
if !matches!(current_input, NodeInput::Node { .. } | NodeInput::Import { .. }) {
|
||||
// Do not disconnect an already disconnected input
|
||||
if matches!(current_input, NodeInput::Value { .. }) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5723,16 +5723,14 @@ impl Iterator for FlowIter<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum ImportOrExport {
|
||||
Import(usize),
|
||||
Export(usize),
|
||||
}
|
||||
|
||||
/// Represents an input connector with index based on the [`DocumentNode::inputs`] index, not the visible input index
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum InputConnector {
|
||||
#[serde(rename = "node")]
|
||||
Node {
|
||||
@@ -5772,8 +5770,7 @@ impl InputConnector {
|
||||
}
|
||||
|
||||
/// Represents an output connector
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum OutputConnector {
|
||||
#[serde(rename = "node")]
|
||||
Node {
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
use super::document_metadata::{DocumentMetadata, LayerNodeIdentifier};
|
||||
use super::network_interface::NodeNetworkInterface;
|
||||
use crate::messages::frontend::IconName;
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils;
|
||||
use glam::DVec2;
|
||||
use graph_craft::document::{NodeId, NodeNetwork};
|
||||
|
||||
/// Represents an entry in the layer tree hierarchy, sent to the frontend.
|
||||
/// Each entry contains its layer ID and a list of its visible children.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, specta::Type)]
|
||||
pub struct LayerStructureEntry {
|
||||
#[serde(rename = "layerId")]
|
||||
pub layer_id: NodeId,
|
||||
pub children: Vec<LayerStructureEntry>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, specta::Type)]
|
||||
pub struct LayerPanelEntry {
|
||||
pub id: NodeId,
|
||||
#[serde(rename = "implementationName")]
|
||||
pub implementation_name: String,
|
||||
#[serde(rename = "iconName")]
|
||||
pub icon_name: Option<IconName>,
|
||||
pub icon_name: Option<String>,
|
||||
pub alias: String,
|
||||
#[serde(rename = "inSelectedNetwork")]
|
||||
pub in_selected_network: bool,
|
||||
@@ -50,8 +47,7 @@ pub struct LayerPanelEntry {
|
||||
}
|
||||
|
||||
/// IMPORTANT: the same node may appear multiple times.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, Eq, specta::Type)]
|
||||
pub struct SelectedNodes(pub Vec<NodeId>);
|
||||
|
||||
impl SelectedNodes {
|
||||
@@ -161,6 +157,5 @@ impl SelectedNodes {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, Eq, specta::Type)]
|
||||
pub struct CollapsedLayers(pub Vec<LayerNodeIdentifier>);
|
||||
@@ -3,8 +3,7 @@ use glam::{DVec2, IVec2};
|
||||
use graphene_std::{uuid::NodeId, vector::misc::dvec2_to_point};
|
||||
use kurbo::{BezPath, DEFAULT_ACCURACY, Line, Point, Shape};
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct WirePath {
|
||||
#[serde(rename = "pathString")]
|
||||
pub path_string: String,
|
||||
@@ -14,8 +13,7 @@ pub struct WirePath {
|
||||
pub dashed: bool,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct WirePathUpdate {
|
||||
pub id: NodeId,
|
||||
#[serde(rename = "inputIndex")]
|
||||
@@ -25,8 +23,7 @@ pub struct WirePathUpdate {
|
||||
pub wire_path_update: Option<WirePath>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum GraphWireStyle {
|
||||
#[default]
|
||||
Direct = 0,
|
||||
|
||||
@@ -28,7 +28,6 @@ const TEXT_REPLACEMENTS: &[(&str, &str)] = &[
|
||||
),
|
||||
("graphene_core::transform::Footprint", "graphene_core::transform::Footprint"),
|
||||
("\"OptionalF64\":", "\"F64\":"),
|
||||
("\"path_bool_nodes::BooleanOperation\"", "\"vector_types::vector::misc::BooleanOperation\""),
|
||||
];
|
||||
|
||||
pub struct NodeReplacement<'a> {
|
||||
@@ -455,10 +454,10 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
||||
],
|
||||
},
|
||||
// ================================
|
||||
// path bool
|
||||
// path-bool
|
||||
// ================================
|
||||
NodeReplacement {
|
||||
node: graphene_std::path_bool_nodes::boolean_operation::IDENTIFIER,
|
||||
node: graphene_std::path_bool::boolean_operation::IDENTIFIER,
|
||||
aliases: &["graphene_path_bool::BooleanOperationNode", "graphene_std::vector::BooleanOperationNode"],
|
||||
},
|
||||
// ================================
|
||||
@@ -860,10 +859,6 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
||||
node: graphene_std::repeat::repeat_on_points::IDENTIFIER,
|
||||
aliases: &["graphene_core::vector::InstanceOnPointsNode", "core_types::vector::InstanceOnPointsNode"],
|
||||
},
|
||||
NodeReplacement {
|
||||
node: graphene_std::vector::copy_to_points::IDENTIFIER,
|
||||
aliases: &["graphene_core::vector::CopyToPointsNode", "core_types::vector::CopyToPointsNode"],
|
||||
},
|
||||
NodeReplacement {
|
||||
node: graphene_std::vector::jitter_points::IDENTIFIER,
|
||||
aliases: &["graphene_core::vector::JitterPointsNode"],
|
||||
@@ -1713,132 +1708,6 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
|
||||
document.network_interface.set_input(&InputConnector::node(*node_id, 1), old_inputs[2].clone(), network_path);
|
||||
}
|
||||
|
||||
// Migrate old Arrow node from (start, end, shaft_width, head_width, head_length) to (arrow_to, shaft_width, head_width, head_length) with a Transform node for positioning
|
||||
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector_nodes::arrow::IDENTIFIER) && inputs_count == 6 {
|
||||
// Read old start and end values
|
||||
let start = match node.inputs.get(1)? {
|
||||
NodeInput::Value { tagged_value, .. } => {
|
||||
if let TaggedValue::DVec2(v) = *tagged_value.clone().into_inner() {
|
||||
v
|
||||
} else {
|
||||
DVec2::ZERO
|
||||
}
|
||||
}
|
||||
_ => DVec2::ZERO,
|
||||
};
|
||||
let end = match node.inputs.get(2)? {
|
||||
NodeInput::Value { tagged_value, .. } => {
|
||||
if let TaggedValue::DVec2(v) = *tagged_value.clone().into_inner() {
|
||||
v
|
||||
} else {
|
||||
DVec2::new(100., 0.)
|
||||
}
|
||||
}
|
||||
_ => DVec2::new(100., 0.),
|
||||
};
|
||||
|
||||
// Replace inputs with the new node definition (primary + arrow_to + shaft_width + head_width + head_length)
|
||||
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
|
||||
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
|
||||
|
||||
// Preserve primary input connection
|
||||
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), network_path);
|
||||
// Set arrow_to = end - start
|
||||
document
|
||||
.network_interface
|
||||
.set_input(&InputConnector::node(*node_id, 1), NodeInput::value(TaggedValue::DVec2(end - start), false), network_path);
|
||||
// Preserve shaft_width, head_width, head_length (shifted from indices 3,4,5 to 2,3,4)
|
||||
document.network_interface.set_input(&InputConnector::node(*node_id, 2), old_inputs[3].clone(), network_path);
|
||||
document.network_interface.set_input(&InputConnector::node(*node_id, 3), old_inputs[4].clone(), network_path);
|
||||
document.network_interface.set_input(&InputConnector::node(*node_id, 4), old_inputs[5].clone(), network_path);
|
||||
|
||||
// Find downstream connection to insert Transform node
|
||||
let downstream = document
|
||||
.network_interface
|
||||
.outward_wires(network_path)
|
||||
.and_then(|wires| wires.get(&OutputConnector::node(*node_id, 0)))
|
||||
.and_then(|connections| connections.first().cloned());
|
||||
|
||||
if let Some(downstream_input) = downstream {
|
||||
// Create a Transform node with translation = start
|
||||
let Some(transform_node_type) = resolve_network_node_type("Transform") else {
|
||||
log::error!("Transform node definition not found during Arrow migration");
|
||||
return None;
|
||||
};
|
||||
let mut transform_template = transform_node_type.default_node_template();
|
||||
transform_template.document_node.inputs[1] = NodeInput::value(TaggedValue::DVec2(start), false);
|
||||
|
||||
let transform_id = NodeId::new();
|
||||
|
||||
// Position the Transform node to the right of the Arrow node
|
||||
let arrow_position = document.network_interface.position(node_id, network_path).unwrap_or_default();
|
||||
document.network_interface.insert_node(transform_id, transform_template, network_path);
|
||||
document.network_interface.shift_absolute_node_position(&transform_id, arrow_position + IVec2::new(7, 0), network_path);
|
||||
document.network_interface.insert_node_between(&transform_id, &downstream_input, 0, network_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate old Line node from (start, end) to (line_to) with a Transform node for positioning
|
||||
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::line::IDENTIFIER) && inputs_count == 3 {
|
||||
// Read old start and end values
|
||||
let start = match node.inputs.get(1)? {
|
||||
NodeInput::Value { tagged_value, .. } => {
|
||||
if let TaggedValue::DVec2(v) = *tagged_value.clone().into_inner() {
|
||||
v
|
||||
} else {
|
||||
DVec2::ZERO
|
||||
}
|
||||
}
|
||||
_ => DVec2::ZERO,
|
||||
};
|
||||
let end = match node.inputs.get(2)? {
|
||||
NodeInput::Value { tagged_value, .. } => {
|
||||
if let TaggedValue::DVec2(v) = *tagged_value.clone().into_inner() {
|
||||
v
|
||||
} else {
|
||||
DVec2::new(100., 100.)
|
||||
}
|
||||
}
|
||||
_ => DVec2::new(100., 100.),
|
||||
};
|
||||
|
||||
// Replace inputs with the new node definition (primary + line_to)
|
||||
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
|
||||
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
|
||||
|
||||
// Preserve primary input connection
|
||||
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), network_path);
|
||||
// Set line_to = end - start
|
||||
document
|
||||
.network_interface
|
||||
.set_input(&InputConnector::node(*node_id, 1), NodeInput::value(TaggedValue::DVec2(end - start), false), network_path);
|
||||
|
||||
// Find downstream connection to insert Transform node
|
||||
let downstream = document
|
||||
.network_interface
|
||||
.outward_wires(network_path)
|
||||
.and_then(|wires| wires.get(&OutputConnector::node(*node_id, 0)))
|
||||
.and_then(|connections| connections.first().cloned());
|
||||
|
||||
if let Some(downstream_input) = downstream {
|
||||
// Create a Transform node with translation = start
|
||||
let Some(transform_node_type) = resolve_network_node_type("Transform") else {
|
||||
log::error!("Transform node definition not found during Line migration");
|
||||
return None;
|
||||
};
|
||||
let mut transform_template = transform_node_type.default_node_template();
|
||||
transform_template.document_node.inputs[1] = NodeInput::value(TaggedValue::DVec2(start), false);
|
||||
|
||||
let transform_id = NodeId::new();
|
||||
|
||||
// Position the Transform node to the right of the Line node
|
||||
let line_position = document.network_interface.position(node_id, network_path).unwrap_or_default();
|
||||
document.network_interface.insert_node(transform_id, transform_template, network_path);
|
||||
document.network_interface.shift_absolute_node_position(&transform_id, line_position + IVec2::new(7, 0), network_path);
|
||||
document.network_interface.insert_node_between(&transform_id, &downstream_input, 0, network_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Add context features to nodes that don't have them (fine-grained context caching migration)
|
||||
if node.context_features == graphene_std::ContextDependencies::default()
|
||||
&& let Some(reference) = document.network_interface.reference(node_id, network_path).clone()
|
||||
|
||||
@@ -485,10 +485,9 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
let name = path.file_stem().map(|n| n.to_string_lossy().to_string());
|
||||
match Self::read_file(&path, content) {
|
||||
FileContent::Document(content) => {
|
||||
let document_path = if path.is_absolute() { Some(path) } else { None };
|
||||
responses.add(PortfolioMessage::OpenDocumentFile {
|
||||
document_name: name,
|
||||
document_path,
|
||||
document_path: Some(path),
|
||||
document_serialized_content: content,
|
||||
});
|
||||
}
|
||||
@@ -1012,11 +1011,12 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
PortfolioMessage::RequestWelcomeScreenButtonsLayout => {
|
||||
let donate = "https://graphite.art/donate/";
|
||||
|
||||
let table = LayoutGroup::table(
|
||||
vec![
|
||||
let table = LayoutGroup::Table {
|
||||
unstyled: true,
|
||||
rows: vec![
|
||||
vec![
|
||||
TextButton::new("New Document")
|
||||
.icon("File")
|
||||
.icon(Some("File".into()))
|
||||
.flush(true)
|
||||
.on_commit(|_| DialogMessage::RequestNewDocumentDialog.into())
|
||||
.widget_instance(),
|
||||
@@ -1024,7 +1024,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
],
|
||||
vec![
|
||||
TextButton::new("Open Document")
|
||||
.icon("Folder")
|
||||
.icon(Some("Folder".into()))
|
||||
.flush(true)
|
||||
.on_commit(|_| PortfolioMessage::Open.into())
|
||||
.widget_instance(),
|
||||
@@ -1032,21 +1032,20 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
],
|
||||
vec![
|
||||
TextButton::new("Open Demo Artwork")
|
||||
.icon("Image")
|
||||
.icon(Some("Image".into()))
|
||||
.flush(true)
|
||||
.on_commit(|_| DialogMessage::RequestDemoArtworkDialog.into())
|
||||
.widget_instance(),
|
||||
],
|
||||
vec![
|
||||
TextButton::new("Support the Development Fund")
|
||||
.icon("Heart")
|
||||
.icon(Some("Heart".into()))
|
||||
.flush(true)
|
||||
.on_commit(move |_| FrontendMessage::TriggerVisitLink { url: donate.to_string() }.into())
|
||||
.widget_instance(),
|
||||
],
|
||||
],
|
||||
true,
|
||||
);
|
||||
};
|
||||
|
||||
responses.add(LayoutMessage::DestroyLayout {
|
||||
layout_target: LayoutTarget::WelcomeScreenButtons,
|
||||
@@ -1058,11 +1057,11 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
}
|
||||
PortfolioMessage::RequestStatusBarInfoLayout => {
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
let widgets = vec![TextLabel::new("Graphite 1.0.0-RC4").disabled(true).widget_instance()]; // TODO: After the RCs, call this "Graphite (beta) x.y.z"
|
||||
let widgets = vec![TextLabel::new("Graphite 1.0.0-RC3").disabled(true).widget_instance()]; // TODO: After the RCs, call this "Graphite (beta) x.y.z"
|
||||
#[cfg(target_family = "wasm")]
|
||||
let widgets = vec![];
|
||||
|
||||
let row = LayoutGroup::row(widgets);
|
||||
let row = LayoutGroup::Row { widgets };
|
||||
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout(vec![row]),
|
||||
@@ -1192,6 +1191,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
Ok(message) => responses.add_front(message),
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
PortfolioMessage::SubmitEyedropperPreviewRender => {
|
||||
use crate::consts::EYEDROPPER_PREVIEW_AREA_RESOLUTION;
|
||||
|
||||
@@ -1223,6 +1223,10 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
Ok(message) => responses.add_front(message),
|
||||
}
|
||||
}
|
||||
#[cfg(target_family = "wasm")]
|
||||
PortfolioMessage::SubmitEyedropperPreviewRender => {
|
||||
// TODO: Currently for Wasm, this is implemented through SVG rendering but the Eyedropper tool doesn't work at all when Vello is enabled as the renderer
|
||||
}
|
||||
PortfolioMessage::ToggleFocusDocument => {
|
||||
self.focus_document = !self.focus_document;
|
||||
responses.add(MenuBarMessage::SendLayout);
|
||||
|
||||
@@ -6,38 +6,16 @@ use crate::messages::prelude::*;
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub enum PreferencesMessage {
|
||||
// Management messages
|
||||
Load {
|
||||
preferences: PreferencesMessageHandler,
|
||||
},
|
||||
Load { preferences: PreferencesMessageHandler },
|
||||
ResetToDefaults,
|
||||
|
||||
// Per-preference messages
|
||||
SelectionMode {
|
||||
selection_mode: SelectionMode,
|
||||
},
|
||||
BrushTool {
|
||||
enabled: bool,
|
||||
},
|
||||
ModifyLayout {
|
||||
zoom_with_scroll: bool,
|
||||
},
|
||||
GraphWireStyle {
|
||||
style: GraphWireStyle,
|
||||
},
|
||||
ViewportZoomWheelRate {
|
||||
rate: f64,
|
||||
},
|
||||
UIScale {
|
||||
scale: f64,
|
||||
},
|
||||
MaxRenderRegionSize {
|
||||
size: u32,
|
||||
},
|
||||
DisableUIAcceleration {
|
||||
disable_ui_acceleration: bool,
|
||||
},
|
||||
#[cfg(target_os = "macos")]
|
||||
VSync {
|
||||
vsync: bool,
|
||||
},
|
||||
SelectionMode { selection_mode: SelectionMode },
|
||||
BrushTool { enabled: bool },
|
||||
ModifyLayout { zoom_with_scroll: bool },
|
||||
GraphWireStyle { style: GraphWireStyle },
|
||||
ViewportZoomWheelRate { rate: f64 },
|
||||
UIScale { scale: f64 },
|
||||
DisableUIAcceleration { disable_ui_acceleration: bool },
|
||||
MaxRenderRegionSize { size: u32 },
|
||||
}
|
||||
@@ -11,8 +11,7 @@ pub struct PreferencesMessageContext<'a> {
|
||||
pub tool_message_handler: &'a ToolMessageHandler,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, ExtractField)]
|
||||
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, specta::Type, ExtractField)]
|
||||
#[serde(default)]
|
||||
pub struct PreferencesMessageHandler {
|
||||
pub selection_mode: SelectionMode,
|
||||
@@ -21,23 +20,13 @@ pub struct PreferencesMessageHandler {
|
||||
pub graph_wire_style: GraphWireStyle,
|
||||
pub viewport_zoom_wheel_rate: f64,
|
||||
pub ui_scale: f64,
|
||||
pub max_render_region_size: u32,
|
||||
pub disable_ui_acceleration: bool,
|
||||
#[cfg(target_os = "macos")]
|
||||
pub vsync: bool,
|
||||
pub max_render_region_size: u32,
|
||||
}
|
||||
|
||||
impl PreferencesMessageHandler {
|
||||
pub fn preferences_requiring_restart(&self, other: &Self) -> Vec<String> {
|
||||
let mut requiring_restart = Vec::new();
|
||||
if self.disable_ui_acceleration != other.disable_ui_acceleration {
|
||||
requiring_restart.push("Disable UI Acceleration");
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
if self.vsync != other.vsync {
|
||||
requiring_restart.push("Enable V-Sync");
|
||||
}
|
||||
requiring_restart.into_iter().map(String::from).collect()
|
||||
pub fn needs_restart(&self, other: &Self) -> bool {
|
||||
self.disable_ui_acceleration != other.disable_ui_acceleration
|
||||
}
|
||||
|
||||
pub fn get_selection_mode(&self) -> SelectionMode {
|
||||
@@ -64,10 +53,8 @@ impl Default for PreferencesMessageHandler {
|
||||
graph_wire_style: GraphWireStyle::default(),
|
||||
viewport_zoom_wheel_rate: VIEWPORT_ZOOM_WHEEL_RATE,
|
||||
ui_scale: UI_SCALE_DEFAULT,
|
||||
max_render_region_size: EditorPreferences::default().max_render_region_size,
|
||||
disable_ui_acceleration: false,
|
||||
#[cfg(target_os = "macos")]
|
||||
vsync: false,
|
||||
max_render_region_size: EditorPreferences::default().max_render_region_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,18 +111,14 @@ impl MessageHandler<PreferencesMessage, PreferencesMessageContext<'_>> for Prefe
|
||||
self.ui_scale = scale;
|
||||
responses.add(FrontendMessage::UpdateUIScale { scale: self.ui_scale });
|
||||
}
|
||||
PreferencesMessage::DisableUIAcceleration { disable_ui_acceleration } => {
|
||||
self.disable_ui_acceleration = disable_ui_acceleration;
|
||||
}
|
||||
PreferencesMessage::MaxRenderRegionSize { size } => {
|
||||
self.max_render_region_size = size;
|
||||
responses.add(PortfolioMessage::EditorPreferences);
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
PreferencesMessage::DisableUIAcceleration { disable_ui_acceleration } => {
|
||||
self.disable_ui_acceleration = disable_ui_acceleration;
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
PreferencesMessage::VSync { vsync } => {
|
||||
self.vsync = vsync;
|
||||
}
|
||||
}
|
||||
|
||||
responses.add(FrontendMessage::TriggerSavePreferences { preferences: self.clone() });
|
||||
|
||||
Loaded 100 of 501 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user