mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-01 07:24:56 -10:00
Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32611aaa33 | ||
|
|
a3f88b0f96 | ||
|
|
a18b7ff79d | ||
|
|
6d0357bbcf | ||
|
|
81d0b8b8d4 | ||
|
|
116a4106c4 | ||
|
|
2ac82a10b5 | ||
|
|
90533e656f | ||
|
|
58aae4f87b | ||
|
|
095c2a6d47 | ||
|
|
35b812ccfe | ||
|
|
8e52309bb0 | ||
|
|
3a7a5f5953 | ||
|
|
b1933e3bcb | ||
|
|
2910e50b2f | ||
|
|
e7a2800665 | ||
|
|
9f9dd71e91 | ||
|
|
20501cac96 | ||
|
|
4300a885dc | ||
|
|
f06983d072 | ||
|
|
52d2b38a82 | ||
|
|
fbd2658148 | ||
|
|
3d1491ce92 | ||
|
|
5d22292072 |
No files matched your search
@@ -25,7 +25,7 @@ jobs:
|
|||||||
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
|
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
|
||||||
|
|
||||||
- name: Build Nix Package
|
- name: Build Nix Package
|
||||||
run: nix build .nix --no-link --print-out-paths
|
run: nix build --no-link --print-out-paths
|
||||||
|
|
||||||
- name: Push to Nix Cache
|
- name: Push to Nix Cache
|
||||||
if: github.ref == 'refs/heads/master' || inputs.push_to_cache == true
|
if: github.ref == 'refs/heads/master' || inputs.push_to_cache == true
|
||||||
@@ -33,10 +33,10 @@ jobs:
|
|||||||
NIX_CACHE_AUTH_TOKEN: ${{ secrets.NIX_CACHE_AUTH_TOKEN }}
|
NIX_CACHE_AUTH_TOKEN: ${{ secrets.NIX_CACHE_AUTH_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
nix run nixpkgs#cachix -- authtoken $NIX_CACHE_AUTH_TOKEN
|
nix run nixpkgs#cachix -- authtoken $NIX_CACHE_AUTH_TOKEN
|
||||||
nix build .nix --no-link --print-out-paths | nix run nixpkgs#cachix -- push graphite
|
nix build --no-link --print-out-paths | nix run nixpkgs#cachix -- push graphite
|
||||||
|
|
||||||
- name: Build Linux Bundle
|
- name: Build Linux Bundle
|
||||||
run: nix build .nix#graphite-bundle.tar.xz && cp ./result ./graphite-linux-bundle.tar.xz
|
run: nix build .#graphite-bundle.tar.xz && cp ./result ./graphite-linux-bundle.tar.xz
|
||||||
|
|
||||||
- name: Upload Linux Bundle
|
- name: Upload Linux Bundle
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@@ -53,7 +53,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Flatpak
|
- name: Build Flatpak
|
||||||
run: |
|
run: |
|
||||||
nix build .nix#graphite-flatpak-manifest
|
nix build .#graphite-flatpak-manifest
|
||||||
|
|
||||||
rm -rf .flatpak
|
rm -rf .flatpak
|
||||||
mkdir -p .flatpak
|
mkdir -p .flatpak
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
- name: Build Mac Bundle
|
- name: Build Mac Bundle
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
run: npm run build-desktop
|
run: cargo run build desktop
|
||||||
|
|
||||||
- name: Stage Artifacts
|
- name: Stage Artifacts
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -14,4 +14,4 @@ jobs:
|
|||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
|
|
||||||
- name: Build Nix Package Dev
|
- name: Build Nix Package Dev
|
||||||
run: nix build .nix#graphite-dev --print-build-logs
|
run: nix build .#graphite-dev --print-build-logs
|
||||||
@@ -52,9 +52,7 @@ jobs:
|
|||||||
- name: 🌐 Build Graphite web code
|
- name: 🌐 Build Graphite web code
|
||||||
env:
|
env:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
run: |
|
run: mold -run cargo run build web
|
||||||
cd frontend
|
|
||||||
mold -run npm run build
|
|
||||||
|
|
||||||
- name: 📤 Publish to Cloudflare Pages
|
- name: 📤 Publish to Cloudflare Pages
|
||||||
id: cloudflare
|
id: cloudflare
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ jobs:
|
|||||||
shell: bash # `cargo-about` refuses to run in powershell
|
shell: bash # `cargo-about` refuses to run in powershell
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
run: npm run build-desktop
|
run: cargo run build desktop
|
||||||
|
|
||||||
- name: Stage Artifacts
|
- name: Stage Artifacts
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ jobs:
|
|||||||
if: steps.skip-check.outputs.skip-check != 'true'
|
if: steps.skip-check.outputs.skip-check != 'true'
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 'latest'
|
node-version: "latest"
|
||||||
|
|
||||||
- name: 🚧 Install build dependencies
|
- name: 🚧 Install build dependencies
|
||||||
if: steps.skip-check.outputs.skip-check != 'true'
|
if: steps.skip-check.outputs.skip-check != 'true'
|
||||||
@@ -98,9 +98,7 @@ jobs:
|
|||||||
if: steps.skip-check.outputs.skip-check != 'true'
|
if: steps.skip-check.outputs.skip-check != 'true'
|
||||||
env:
|
env:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
run: |
|
run: mold -run cargo run build web
|
||||||
cd frontend
|
|
||||||
mold -run npm run build
|
|
||||||
|
|
||||||
- name: 📤 Publish to Cloudflare Pages
|
- name: 📤 Publish to Cloudflare Pages
|
||||||
if: steps.skip-check.outputs.skip-check != 'true'
|
if: steps.skip-check.outputs.skip-check != 'true'
|
||||||
@@ -119,7 +117,7 @@ jobs:
|
|||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
run: |
|
run: |
|
||||||
cd frontend
|
cd frontend
|
||||||
npm run lint
|
npm run check
|
||||||
|
|
||||||
# Run the Rust tests on the self-hosted native runner
|
# Run the Rust tests on the self-hosted native runner
|
||||||
test:
|
test:
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# USAGE:
|
# USAGE:
|
||||||
# After reviewing the code, core team members may comment on a PR with the exact text:
|
# 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-debug` 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
|
# - `!build` to build without debug symbols and optimizations enabled
|
||||||
# The comment may not contain any other text, not even whitespace or newlines.
|
# The comment may not contain any other text, not even whitespace or newlines.
|
||||||
name: "!build PR Command"
|
name: "!build PR Command"
|
||||||
@@ -21,7 +20,7 @@ jobs:
|
|||||||
if: >
|
if: >
|
||||||
github.event.issue.pull_request &&
|
github.event.issue.pull_request &&
|
||||||
github.event.comment.author_association == 'MEMBER' &&
|
github.event.comment.author_association == 'MEMBER' &&
|
||||||
(github.event.comment.body == '!build-dev' || github.event.comment.body == '!build-profiling' || github.event.comment.body == '!build')
|
(github.event.comment.body == '!build-debug' || github.event.comment.body == '!build')
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -82,14 +81,12 @@ jobs:
|
|||||||
- name: ⌨ Set build command based on comment
|
- name: ⌨ Set build command based on comment
|
||||||
id: build_command
|
id: build_command
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ github.event.comment.body }}" == "!build-dev" ]]; then
|
if [[ "${{ github.event.comment.body }}" == "!build-debug" ]]; then
|
||||||
echo "command=build-dev" >> $GITHUB_OUTPUT
|
echo "command=build web debug" >> $GITHUB_OUTPUT
|
||||||
elif [[ "${{ github.event.comment.body }}" == "!build-profiling" ]]; then
|
|
||||||
echo "command=build-profiling" >> $GITHUB_OUTPUT
|
|
||||||
elif [[ "${{ github.event.comment.body }}" == "!build" ]]; then
|
elif [[ "${{ github.event.comment.body }}" == "!build" ]]; then
|
||||||
echo "command=build" >> $GITHUB_OUTPUT
|
echo "command=build web" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "Failed to detect if the build command written in the comment should have been '!build-dev', '!build-profiling', or '!build'" >> $GITHUB_OUTPUT
|
echo "Failed to detect if the build command written in the comment should have been '!build-debug', or '!build'" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 💬 Comment Actions run link
|
- name: 💬 Comment Actions run link
|
||||||
@@ -108,9 +105,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
if: ${{ success() || failure()}}
|
if: ${{ success() || failure()}}
|
||||||
run: |
|
run: mold -run cargo run ${{ steps.build_command.outputs.command }}
|
||||||
cd frontend
|
|
||||||
mold -run npm run ${{ steps.build_command.outputs.command }}
|
|
||||||
|
|
||||||
- name: ❗ Warn on build failure
|
- name: ❗ Warn on build failure
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
- name: 🟢 Install the latest Node.js
|
- name: 🟢 Install the latest Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 'latest'
|
node-version: "latest"
|
||||||
|
|
||||||
- name: 🚧 Install build dependencies
|
- name: 🚧 Install build dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -49,9 +49,7 @@ jobs:
|
|||||||
- name: 🌐 Build Graphite web code
|
- name: 🌐 Build Graphite web code
|
||||||
env:
|
env:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
run: |
|
run: mold -run cargo run build web
|
||||||
cd frontend
|
|
||||||
mold -run npm run build
|
|
||||||
|
|
||||||
- name: 📤 Publish to Cloudflare Pages
|
- name: 📤 Publish to Cloudflare Pages
|
||||||
id: cloudflare
|
id: cloudflare
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ jobs:
|
|||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
|
|
||||||
- name: Build graphene raster nodes shaders
|
- name: Build graphene raster nodes shaders
|
||||||
run: nix build .nix#graphite-raster-nodes-shaders && cp result raster_nodes_shaders_entrypoint.wgsl
|
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: |
|
run: |
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd website
|
cd website
|
||||||
npm ci
|
npm ci
|
||||||
npm run lint
|
npm run check
|
||||||
zola --config config.toml build --minify
|
zola --config config.toml build --minify
|
||||||
|
|
||||||
- name: 📤 Publish to Cloudflare Pages
|
- name: 📤 Publish to Cloudflare Pages
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
-110
@@ -1,110 +0,0 @@
|
|||||||
# 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);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# 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
+1
-14
@@ -39,25 +39,12 @@
|
|||||||
"rust-analyzer.check.command": "clippy",
|
"rust-analyzer.check.command": "clippy",
|
||||||
"rust-analyzer.cargo.allTargets": false,
|
"rust-analyzer.cargo.allTargets": false,
|
||||||
"rust-analyzer.procMacro.ignored": {
|
"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 config
|
||||||
"eslint.format.enable": true,
|
"eslint.format.enable": true,
|
||||||
"eslint.workingDirectories": ["./frontend", "./website"],
|
"eslint.workingDirectories": ["./frontend", "./website"],
|
||||||
"eslint.validate": ["javascript", "typescript", "svelte"],
|
"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 config
|
||||||
"git-graph.repository.fetchAndPrune": true,
|
"git-graph.repository.fetchAndPrune": true,
|
||||||
"git-graph.repository.showRemoteHeads": false,
|
"git-graph.repository.showRemoteHeads": false,
|
||||||
|
|||||||
Generated
+117
-600
File diff suppressed because it is too large.
Load diff
+9
-14
@@ -10,7 +10,6 @@ members = [
|
|||||||
"editor",
|
"editor",
|
||||||
"frontend/wasm",
|
"frontend/wasm",
|
||||||
"libraries/dyn-any",
|
"libraries/dyn-any",
|
||||||
"libraries/path-bool",
|
|
||||||
"libraries/math-parser",
|
"libraries/math-parser",
|
||||||
"node-graph/libraries/*",
|
"node-graph/libraries/*",
|
||||||
"node-graph/nodes/*",
|
"node-graph/nodes/*",
|
||||||
@@ -23,6 +22,7 @@ members = [
|
|||||||
"node-graph/node-macro",
|
"node-graph/node-macro",
|
||||||
"node-graph/preprocessor",
|
"node-graph/preprocessor",
|
||||||
"proc-macros",
|
"proc-macros",
|
||||||
|
"tools/cargo-run",
|
||||||
"tools/crate-hierarchy-viz",
|
"tools/crate-hierarchy-viz",
|
||||||
"tools/third-party-licenses",
|
"tools/third-party-licenses",
|
||||||
"tools/editor-message-tree",
|
"tools/editor-message-tree",
|
||||||
@@ -32,15 +32,14 @@ default-members = [
|
|||||||
"editor",
|
"editor",
|
||||||
"frontend/wasm",
|
"frontend/wasm",
|
||||||
"libraries/dyn-any",
|
"libraries/dyn-any",
|
||||||
"libraries/path-bool",
|
|
||||||
"libraries/math-parser",
|
"libraries/math-parser",
|
||||||
"node-graph/graph-craft",
|
"node-graph/graph-craft",
|
||||||
"node-graph/graphene-cli",
|
|
||||||
"node-graph/interpreted-executor",
|
"node-graph/interpreted-executor",
|
||||||
"node-graph/node-macro",
|
"node-graph/node-macro",
|
||||||
"node-graph/preprocessor",
|
"node-graph/preprocessor",
|
||||||
# blocked by https://github.com/rust-lang/cargo/issues/16000
|
# blocked by https://github.com/rust-lang/cargo/issues/16000
|
||||||
# "proc-macros",
|
# "proc-macros",
|
||||||
|
"tools/cargo-run",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
@@ -66,7 +65,6 @@ dyn-any = { path = "libraries/dyn-any", features = [
|
|||||||
] }
|
] }
|
||||||
preprocessor = { path = "node-graph/preprocessor" }
|
preprocessor = { path = "node-graph/preprocessor" }
|
||||||
math-parser = { path = "libraries/math-parser" }
|
math-parser = { path = "libraries/math-parser" }
|
||||||
path-bool = { path = "libraries/path-bool" }
|
|
||||||
graphene-application-io = { path = "node-graph/libraries/application-io" }
|
graphene-application-io = { path = "node-graph/libraries/application-io" }
|
||||||
core-types = { path = "node-graph/libraries/core-types" }
|
core-types = { path = "node-graph/libraries/core-types" }
|
||||||
no-std-types = { path = "node-graph/libraries/no-std-types" }
|
no-std-types = { path = "node-graph/libraries/no-std-types" }
|
||||||
@@ -97,6 +95,7 @@ rustc-hash = "2.0"
|
|||||||
bytemuck = { version = "1.13", features = ["derive", "min_const_generics"] }
|
bytemuck = { version = "1.13", features = ["derive", "min_const_generics"] }
|
||||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
serde_bytes = "0.11"
|
||||||
serde-wasm-bindgen = "0.6"
|
serde-wasm-bindgen = "0.6"
|
||||||
reqwest = { version = "0.13", features = ["blocking", "json"] }
|
reqwest = { version = "0.13", features = ["blocking", "json"] }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
@@ -168,17 +167,14 @@ image = { version = "0.25", default-features = false, features = [
|
|||||||
"png",
|
"png",
|
||||||
"jpeg",
|
"jpeg",
|
||||||
"bmp",
|
"bmp",
|
||||||
|
"gif",
|
||||||
] }
|
] }
|
||||||
pretty_assertions = "1.4"
|
pretty_assertions = "1.4"
|
||||||
fern = { version = "0.7", features = ["colored"] }
|
fern = { version = "0.7", features = ["colored"] }
|
||||||
num_enum = { version = "0.7", default-features = false }
|
num_enum = { version = "0.7", default-features = false }
|
||||||
num-derive = "0.4"
|
num-derive = "0.4"
|
||||||
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
|
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
|
||||||
specta = { version = "2.0.0-rc.22", features = [
|
tsify = { version = "0.5", default-features = false, features = ["js"] }
|
||||||
"glam",
|
|
||||||
"derive",
|
|
||||||
# "typescript",
|
|
||||||
] }
|
|
||||||
syn = { version = "2.0", default-features = false, features = [
|
syn = { version = "2.0", default-features = false, features = [
|
||||||
"full",
|
"full",
|
||||||
"derive",
|
"derive",
|
||||||
@@ -213,6 +209,8 @@ cargo-gpu = { git = "https://github.com/Firestar99/cargo-gpu", rev = "3952a22d16
|
|||||||
qrcodegen = "1.8"
|
qrcodegen = "1.8"
|
||||||
lzma-rust2 = { version = "0.16", default-features = false, features = ["std", "encoder", "optimization", "xz"] }
|
lzma-rust2 = { version = "0.16", default-features = false, features = ["std", "encoder", "optimization", "xz"] }
|
||||||
scraper = "0.25"
|
scraper = "0.25"
|
||||||
|
linesweeper = "0.3"
|
||||||
|
smallvec = "1.13.2"
|
||||||
|
|
||||||
[workspace.lints.rust]
|
[workspace.lints.rust]
|
||||||
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
|
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
|
||||||
@@ -228,7 +226,6 @@ graphite-proc-macros = { opt-level = 1 }
|
|||||||
image = { opt-level = 2 }
|
image = { opt-level = 2 }
|
||||||
rustc-hash = { opt-level = 3 }
|
rustc-hash = { opt-level = 3 }
|
||||||
serde_derive = { opt-level = 1 }
|
serde_derive = { opt-level = 1 }
|
||||||
specta-macros = { opt-level = 1 }
|
|
||||||
syn = { opt-level = 1 }
|
syn = { opt-level = 1 }
|
||||||
node-macro = { opt-level = 2 }
|
node-macro = { opt-level = 2 }
|
||||||
|
|
||||||
@@ -236,11 +233,9 @@ node-macro = { opt-level = 2 }
|
|||||||
lto = "thin"
|
lto = "thin"
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
[profile.profiling]
|
|
||||||
inherits = "release"
|
|
||||||
debug = true
|
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
# Force cargo to use only one version of the dpi crate (vendoring breaks without this)
|
# Force cargo to use only one version of the dpi crate (vendoring breaks without this)
|
||||||
dpi = { git = "https://github.com/rust-windowing/winit.git" }
|
dpi = { git = "https://github.com/rust-windowing/winit.git" }
|
||||||
download-cef = { git = "https://github.com/timon-schelling/cef-rs.git", branch = "graphite" }
|
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" }
|
||||||
@@ -183,7 +183,7 @@ allow-git = []
|
|||||||
|
|
||||||
[sources.allow-org]
|
[sources.allow-org]
|
||||||
# 1 or more github.com organizations to allow git sources for
|
# 1 or more github.com organizations to allow git sources for
|
||||||
github = ["linebender", "Rust-GPU", "specta-rs"]
|
github = ["linebender", "Rust-GPU"]
|
||||||
# 1 or more gitlab.com organizations to allow git sources for
|
# 1 or more gitlab.com organizations to allow git sources for
|
||||||
#gitlab = [""]
|
#gitlab = [""]
|
||||||
# 1 or more bitbucket.org organizations to allow git sources for
|
# 1 or more bitbucket.org organizations to allow git sources for
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![cfg_attr(target_os = "linux", allow(unused))] // TODO: Remove this when bundling for linux is implemented
|
||||||
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
@@ -27,8 +29,7 @@ pub(crate) fn cef_path() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn build_bin(package: &str, bin: Option<&str>) -> Result<PathBuf, Box<dyn Error>> {
|
pub(crate) fn build_bin(package: &str, bin: Option<&str>) -> Result<PathBuf, Box<dyn Error>> {
|
||||||
let profile = &profile_name();
|
let mut args = vec!["build", "--package", package, "--profile", profile_name()];
|
||||||
let mut args = vec!["build", "--package", package, "--profile", profile];
|
|
||||||
if let Some(bin) = bin {
|
if let Some(bin) = bin {
|
||||||
args.push("--bin");
|
args.push("--bin");
|
||||||
args.push(bin);
|
args.push(bin);
|
||||||
@@ -45,7 +46,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>> {
|
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()?;
|
let status = Command::new(program).args(args).stdout(Stdio::inherit()).stderr(Stdio::inherit()).status()?;
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
std::process::exit(1);
|
return Err(format!("Command '{}' with args {:?} failed with status: {}", program, args, status).into());
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
use std::error::Error;
|
|
||||||
|
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
|
|
||||||
pub fn main() -> Result<(), Box<dyn Error>> {
|
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let app_bin = build_bin("graphite-desktop-platform-linux", None)?;
|
let app_bin = build_bin("graphite-desktop-platform-linux", None)?;
|
||||||
|
|
||||||
// TODO: Implement bundling for linux
|
// TODO: Implement bundling for linux
|
||||||
|
|
||||||
// TODO: Consider adding more useful cli
|
// TODO: Consider adding more useful cli
|
||||||
if std::env::args().any(|a| a == "open") {
|
let args: Vec<String> = std::env::args().collect();
|
||||||
run_command(&app_bin.to_string_lossy(), &[]).expect("failed to open app");
|
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");
|
||||||
} else {
|
} else {
|
||||||
println!("Binary built and placed at {}", app_bin.to_string_lossy());
|
eprintln!("Binary built and placed at {}", app_bin.to_string_lossy());
|
||||||
eprintln!("Bundling for Linux is not yet implemented.");
|
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`");
|
eprintln!("You can still start the app with the `open` subcommand. `cargo run -p graphite-desktop-bundle -- open`");
|
||||||
std::process::exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
let app_dir = bundle(&profile_path, &app_bin, &helper_bin);
|
let app_dir = bundle(&profile_path, &app_bin, &helper_bin);
|
||||||
|
|
||||||
// TODO: Consider adding more useful cli
|
// TODO: Consider adding more useful cli
|
||||||
if std::env::args().any(|a| a == "open") {
|
let args: Vec<String> = std::env::args().collect();
|
||||||
let executable_path = app_dir.join(EXEC_PATH).join(APP_NAME);
|
if let Some(pos) = args.iter().position(|a| a == "open") {
|
||||||
run_command(&executable_path.to_string_lossy(), &[]).expect("failed to open app");
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
let executable = bundle(&profile_path(), &app_bin);
|
let executable = bundle(&profile_path(), &app_bin);
|
||||||
|
|
||||||
// TODO: Consider adding more useful cli
|
// TODO: Consider adding more useful cli
|
||||||
if std::env::args().any(|a| a == "open") {
|
let args: Vec<String> = std::env::args().collect();
|
||||||
let executable_path = executable.to_string_lossy();
|
if let Some(pos) = args.iter().position(|a| a == "open") {
|
||||||
run_command(&executable_path, &[]).expect("failed to open app")
|
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
+11
-2
@@ -21,7 +21,7 @@ use crate::persist::PersistentData;
|
|||||||
use crate::preferences;
|
use crate::preferences;
|
||||||
use crate::render::{RenderError, RenderState};
|
use crate::render::{RenderError, RenderState};
|
||||||
use crate::window::Window;
|
use crate::window::Window;
|
||||||
use crate::wrapper::messages::{DesktopFrontendMessage, DesktopWrapperMessage, InputMessage, MouseKeys, MouseState};
|
use crate::wrapper::messages::{DesktopFrontendMessage, DesktopWrapperMessage, InputMessage, MouseKeys, MouseState, Preferences};
|
||||||
use crate::wrapper::{DesktopWrapper, NodeGraphExecutionResult, WgpuContext, serialize_frontend_messages};
|
use crate::wrapper::{DesktopWrapper, NodeGraphExecutionResult, WgpuContext, serialize_frontend_messages};
|
||||||
|
|
||||||
pub(crate) struct App {
|
pub(crate) struct App {
|
||||||
@@ -46,6 +46,8 @@ pub(crate) struct App {
|
|||||||
web_communication_initialized: bool,
|
web_communication_initialized: bool,
|
||||||
web_communication_startup_buffer: Vec<Vec<u8>>,
|
web_communication_startup_buffer: Vec<Vec<u8>>,
|
||||||
persistent_data: PersistentData,
|
persistent_data: PersistentData,
|
||||||
|
#[cfg_attr(not(target_os = "macos"), expect(unused))]
|
||||||
|
preferences: Preferences,
|
||||||
cli: Cli,
|
cli: Cli,
|
||||||
startup_time: Option<Instant>,
|
startup_time: Option<Instant>,
|
||||||
exiting: Arc<AtomicBool>,
|
exiting: Arc<AtomicBool>,
|
||||||
@@ -63,6 +65,7 @@ impl App {
|
|||||||
wgpu_context: WgpuContext,
|
wgpu_context: WgpuContext,
|
||||||
app_event_receiver: Receiver<AppEvent>,
|
app_event_receiver: Receiver<AppEvent>,
|
||||||
app_event_scheduler: AppEventScheduler,
|
app_event_scheduler: AppEventScheduler,
|
||||||
|
preferences: Preferences,
|
||||||
cli: Cli,
|
cli: Cli,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let ctrlc_app_event_scheduler = app_event_scheduler.clone();
|
let ctrlc_app_event_scheduler = app_event_scheduler.clone();
|
||||||
@@ -116,6 +119,7 @@ impl App {
|
|||||||
web_communication_initialized: false,
|
web_communication_initialized: false,
|
||||||
web_communication_startup_buffer: Vec::new(),
|
web_communication_startup_buffer: Vec::new(),
|
||||||
persistent_data,
|
persistent_data,
|
||||||
|
preferences,
|
||||||
cli,
|
cli,
|
||||||
startup_time: None,
|
startup_time: None,
|
||||||
exiting,
|
exiting,
|
||||||
@@ -516,7 +520,12 @@ impl ApplicationHandler for App {
|
|||||||
let window = Window::new(event_loop, self.app_event_scheduler.clone());
|
let window = Window::new(event_loop, self.app_event_scheduler.clone());
|
||||||
self.window = Some(window);
|
self.window = Some(window);
|
||||||
|
|
||||||
let render_state = RenderState::new(self.window.as_ref().unwrap(), self.wgpu_context.clone());
|
#[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);
|
||||||
self.render_state = Some(render_state);
|
self.render_state = Some(render_state);
|
||||||
|
|
||||||
if let Some(window) = &self.window.as_ref() {
|
if let Some(window) = &self.window.as_ref() {
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
use std::path::{Path, PathBuf};
|
|
||||||
|
|
||||||
use cef::args::Args;
|
use cef::args::Args;
|
||||||
use cef::sys::{CEF_API_VERSION_LAST, cef_log_severity_t, cef_resultcode_t};
|
use cef::sys::{CEF_API_VERSION_LAST, cef_log_severity_t};
|
||||||
use cef::{
|
use cef::{
|
||||||
App, BrowserSettings, CefString, Client, DictionaryValue, ImplCommandLine, ImplRequestContext, LogSeverity, RequestContextSettings, SchemeHandlerFactory, Settings, WindowInfo, api_hash,
|
App, BrowserSettings, CefString, Client, DictionaryValue, ImplCommandLine, ImplRequestContext, LogSeverity, RequestContextSettings, SchemeHandlerFactory, Settings, WindowInfo, api_hash,
|
||||||
browser_host_create_browser_sync, execute_process,
|
browser_host_create_browser_sync, execute_process,
|
||||||
};
|
};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use super::CefContext;
|
use super::CefContext;
|
||||||
use super::singlethreaded::SingleThreadedCefContext;
|
use super::singlethreaded::SingleThreadedCefContext;
|
||||||
@@ -138,8 +137,7 @@ impl<H: CefEventHandler> CefContextBuilder<H> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!("Failed to initialize CEF context: {:?}", e);
|
panic!("Failed to initialize CEF context: {:?}", e);
|
||||||
std::process::exit(1);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -153,10 +151,7 @@ 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());
|
let result = cef::initialize(Some(self.args.as_main_args()), Some(&settings), Some(&mut cef_app), std::ptr::null_mut());
|
||||||
if result != 1 {
|
if result != 1 {
|
||||||
let cef_exit_code = cef::get_exit_code() as u32;
|
let cef_exit_code = cef::get_exit_code() as u32;
|
||||||
if cef_exit_code == cef_resultcode_t::CEF_RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED as u32 {
|
return Err(InitError::InitializationFailureCode(cef_exit_code));
|
||||||
return Err(InitError::AlreadyRunning);
|
|
||||||
}
|
|
||||||
return Err(InitError::InitializationFailed(cef_exit_code));
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -228,18 +223,16 @@ fn create_browser<H: CefEventHandler>(event_handler: H, instance_dir: PathBuf, d
|
|||||||
pub(crate) enum SetupError {
|
pub(crate) enum SetupError {
|
||||||
#[error("This is the sub process should exit immediately")]
|
#[error("This is the sub process should exit immediately")]
|
||||||
Subprocess,
|
Subprocess,
|
||||||
#[error("Subprocess returned non zero exit code")]
|
#[error("Subprocess returned non zero exit code: {0}")]
|
||||||
SubprocessFailed(String),
|
SubprocessFailed(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub(crate) enum InitError {
|
pub(crate) enum InitError {
|
||||||
#[error("Initialization failed")]
|
#[error("Initialization failed with code: {0}")]
|
||||||
InitializationFailed(u32),
|
InitializationFailureCode(u32),
|
||||||
#[error("Browser creation failed")]
|
#[error("Browser creation failed")]
|
||||||
BrowserCreationFailed,
|
BrowserCreationFailed,
|
||||||
#[error("Request context creation failed")]
|
#[error("Request context creation failed")]
|
||||||
RequestContextCreationFailed,
|
RequestContextCreationFailed,
|
||||||
#[error("Another instance is already running")]
|
|
||||||
AlreadyRunning,
|
|
||||||
}
|
}
|
||||||
+13
-20
@@ -5,7 +5,6 @@ use crate::consts::APP_LOCK_FILE_NAME;
|
|||||||
use crate::event::CreateAppEventSchedulerEventLoopExt;
|
use crate::event::CreateAppEventSchedulerEventLoopExt;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::process::exit;
|
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
use winit::event_loop::EventLoop;
|
use winit::event_loop::EventLoop;
|
||||||
|
|
||||||
@@ -46,8 +45,7 @@ pub fn start() {
|
|||||||
.truncate(true)
|
.truncate(true)
|
||||||
.open(dirs::app_data_dir().join(APP_LOCK_FILE_NAME))
|
.open(dirs::app_data_dir().join(APP_LOCK_FILE_NAME))
|
||||||
else {
|
else {
|
||||||
tracing::error!("Failed to open lock file, Exiting.");
|
panic!("Failed to open lock file.")
|
||||||
exit(1);
|
|
||||||
};
|
};
|
||||||
let mut lock = fd_lock::RwLock::new(lock_file);
|
let mut lock = fd_lock::RwLock::new(lock_file);
|
||||||
let lock = match lock.try_write() {
|
let lock = match lock.try_write() {
|
||||||
@@ -60,10 +58,12 @@ pub fn start() {
|
|||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
tracing::error!("Another instance is already running, Exiting.");
|
tracing::error!("Another instance is already running, Exiting.");
|
||||||
exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let prefs = preferences::read();
|
||||||
|
|
||||||
// Must be called before event loop initialization or native window integrations will break
|
// Must be called before event loop initialization or native window integrations will break
|
||||||
App::init();
|
App::init();
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ pub fn start() {
|
|||||||
|
|
||||||
let (cef_view_info_sender, cef_view_info_receiver) = std::sync::mpsc::channel();
|
let (cef_view_info_sender, cef_view_info_receiver) = std::sync::mpsc::channel();
|
||||||
|
|
||||||
let disable_ui_acceleration = preferences::read().disable_ui_acceleration || cli.disable_ui_acceleration;
|
let disable_ui_acceleration = prefs.disable_ui_acceleration || cli.disable_ui_acceleration;
|
||||||
if disable_ui_acceleration {
|
if disable_ui_acceleration {
|
||||||
println!("UI acceleration is disabled");
|
println!("UI acceleration is disabled");
|
||||||
}
|
}
|
||||||
@@ -86,25 +86,18 @@ pub fn start() {
|
|||||||
tracing::info!("CEF initialized successfully");
|
tracing::info!("CEF initialized successfully");
|
||||||
context
|
context
|
||||||
}
|
}
|
||||||
Err(cef::InitError::AlreadyRunning) => {
|
Err(cef::InitError::InitializationFailureCode(code)) => {
|
||||||
tracing::error!("Another instance is already running, Exiting.");
|
panic!("CEF initialization failed with code: {code}");
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
Err(cef::InitError::InitializationFailed(code)) => {
|
|
||||||
tracing::error!("Cef initialization failed with code: {code}");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
Err(cef::InitError::BrowserCreationFailed) => {
|
Err(cef::InitError::BrowserCreationFailed) => {
|
||||||
tracing::error!("Failed to create CEF browser");
|
panic!("Failed to create CEF browser");
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
Err(cef::InitError::RequestContextCreationFailed) => {
|
Err(cef::InitError::RequestContextCreationFailed) => {
|
||||||
tracing::error!("Failed to create CEF request context");
|
panic!("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, cli);
|
let app = App::new(Box::new(cef_context), cef_view_info_sender, wgpu_context, app_event_receiver, app_event_scheduler, prefs, cli);
|
||||||
|
|
||||||
let exit_reason = app.run(event_loop);
|
let exit_reason = app.run(event_loop);
|
||||||
|
|
||||||
@@ -120,15 +113,15 @@ pub fn start() {
|
|||||||
drop(lock);
|
drop(lock);
|
||||||
|
|
||||||
match exit_reason {
|
match exit_reason {
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
app::ExitReason::Restart | app::ExitReason::UiAccelerationFailure => {
|
app::ExitReason::Restart | app::ExitReason::UiAccelerationFailure => {
|
||||||
tracing::error!("Restarting application");
|
tracing::error!("Restarting application");
|
||||||
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
|
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
let _ = std::os::unix::process::CommandExt::exec(&mut command);
|
let _ = std::os::unix::process::CommandExt::exec(&mut command);
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
tracing::error!("Failed to restart application");
|
||||||
#[cfg(not(target_family = "unix"))]
|
#[cfg(not(target_family = "unix"))]
|
||||||
let _ = command.spawn();
|
let _ = command.spawn();
|
||||||
tracing::error!("Failed to restart application");
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -139,7 +132,7 @@ pub fn start() {
|
|||||||
// Calling `exit` bypasses rust teardown and lets Windows perform process cleanup.
|
// 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.
|
// TODO: Identify and fix the underlying CEF shutdown issue so this workaround can be removed.
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_helper() {
|
pub fn start_helper() {
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
// =============
|
||||||
|
// VERTEX SHADER
|
||||||
|
// =============
|
||||||
|
|
||||||
struct VertexOutput {
|
struct VertexOutput {
|
||||||
@builtin(position) clip_position: vec4<f32>,
|
@builtin(position) clip_position: vec4<f32>,
|
||||||
@location(0) tex_coords: vec2<f32>,
|
@location(0) tex_coords: vec2<f32>,
|
||||||
@@ -6,19 +10,21 @@ struct VertexOutput {
|
|||||||
@vertex
|
@vertex
|
||||||
fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {
|
fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {
|
||||||
var out: VertexOutput;
|
var out: VertexOutput;
|
||||||
|
|
||||||
let pos = array(
|
let pos = array(
|
||||||
vec2f( -1.0, -1.0),
|
vec2f(-1.0, -1.0),
|
||||||
vec2f( 3.0, -1.0),
|
vec2f(3.0, -1.0),
|
||||||
vec2f( -1.0, 3.0),
|
vec2f(-1.0, 3.0),
|
||||||
);
|
);
|
||||||
let xy = pos[vertex_index];
|
let xy = pos[vertex_index];
|
||||||
out.clip_position = vec4f(xy , 0.0, 1.0);
|
out.clip_position = vec4f(xy, 0.0, 1.0);
|
||||||
let coords = (xy / 2. + 0.5);
|
let coords = xy / 2. + 0.5;
|
||||||
out.tex_coords = vec2f(coords.x, 1. - coords.y);
|
out.tex_coords = vec2f(coords.x, 1. - coords.y);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===============
|
||||||
|
// FRAGMENT SHADER
|
||||||
|
// ===============
|
||||||
|
|
||||||
struct Constants {
|
struct Constants {
|
||||||
viewport_scale: vec2<f32>,
|
viewport_scale: vec2<f32>,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use wgpu::PresentMode;
|
||||||
|
|
||||||
use crate::window::Window;
|
use crate::window::Window;
|
||||||
use crate::wrapper::{TargetTexture, WgpuContext, WgpuExecutor};
|
use crate::wrapper::{TargetTexture, WgpuContext, WgpuExecutor};
|
||||||
@@ -11,13 +12,13 @@ pub(crate) struct RenderState {
|
|||||||
executor: WgpuExecutor,
|
executor: WgpuExecutor,
|
||||||
config: wgpu::SurfaceConfiguration,
|
config: wgpu::SurfaceConfiguration,
|
||||||
render_pipeline: wgpu::RenderPipeline,
|
render_pipeline: wgpu::RenderPipeline,
|
||||||
transparent_texture: wgpu::Texture,
|
transparent_texture: std::sync::Arc<wgpu::Texture>,
|
||||||
sampler: wgpu::Sampler,
|
sampler: wgpu::Sampler,
|
||||||
desired_width: u32,
|
desired_width: u32,
|
||||||
desired_height: u32,
|
desired_height: u32,
|
||||||
viewport_scale: [f32; 2],
|
viewport_scale: [f32; 2],
|
||||||
viewport_offset: [f32; 2],
|
viewport_offset: [f32; 2],
|
||||||
viewport_texture: Option<wgpu::Texture>,
|
viewport_texture: Option<std::sync::Arc<wgpu::Texture>>,
|
||||||
overlays_texture: Option<TargetTexture>,
|
overlays_texture: Option<TargetTexture>,
|
||||||
ui_texture: Option<wgpu::Texture>,
|
ui_texture: Option<wgpu::Texture>,
|
||||||
bind_group: Option<wgpu::BindGroup>,
|
bind_group: Option<wgpu::BindGroup>,
|
||||||
@@ -27,7 +28,7 @@ pub(crate) struct RenderState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RenderState {
|
impl RenderState {
|
||||||
pub(crate) fn new(window: &Window, context: WgpuContext) -> Self {
|
pub(crate) fn new(window: &Window, context: WgpuContext, present_mode: Option<PresentMode>) -> Self {
|
||||||
let size = window.surface_size();
|
let size = window.surface_size();
|
||||||
let surface = window.create_surface(context.instance.clone());
|
let surface = window.create_surface(context.instance.clone());
|
||||||
|
|
||||||
@@ -39,10 +40,7 @@ impl RenderState {
|
|||||||
format: surface_format,
|
format: surface_format,
|
||||||
width: size.width,
|
width: size.width,
|
||||||
height: size.height,
|
height: size.height,
|
||||||
#[cfg(not(target_os = "macos"))]
|
present_mode: present_mode.unwrap_or(surface_caps.present_modes[0]),
|
||||||
present_mode: surface_caps.present_modes[0],
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
present_mode: wgpu::PresentMode::Immediate,
|
|
||||||
alpha_mode: surface_caps.alpha_modes[0],
|
alpha_mode: surface_caps.alpha_modes[0],
|
||||||
view_formats: vec![],
|
view_formats: vec![],
|
||||||
desired_maximum_frame_latency: 1,
|
desired_maximum_frame_latency: 1,
|
||||||
@@ -50,7 +48,7 @@ impl RenderState {
|
|||||||
|
|
||||||
surface.configure(&context.device, &config);
|
surface.configure(&context.device, &config);
|
||||||
|
|
||||||
let transparent_texture = context.device.create_texture(&wgpu::TextureDescriptor {
|
let transparent_texture = std::sync::Arc::new(context.device.create_texture(&wgpu::TextureDescriptor {
|
||||||
label: Some("Transparent Texture"),
|
label: Some("Transparent Texture"),
|
||||||
size: wgpu::Extent3d {
|
size: wgpu::Extent3d {
|
||||||
width: 1,
|
width: 1,
|
||||||
@@ -63,7 +61,7 @@ impl RenderState {
|
|||||||
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
|
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
|
||||||
view_formats: &[],
|
view_formats: &[],
|
||||||
});
|
}));
|
||||||
|
|
||||||
// Create shader module
|
// Create shader module
|
||||||
let shader = context.device.create_shader_module(wgpu::include_wgsl!("composite_shader.wgsl"));
|
let shader = context.device.create_shader_module(wgpu::include_wgsl!("composite_shader.wgsl"));
|
||||||
@@ -207,7 +205,7 @@ impl RenderState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn bind_viewport_texture(&mut self, viewport_texture: wgpu::Texture) {
|
pub(crate) fn bind_viewport_texture(&mut self, viewport_texture: std::sync::Arc<wgpu::Texture>) {
|
||||||
self.viewport_texture = Some(viewport_texture);
|
self.viewport_texture = Some(viewport_texture);
|
||||||
self.update_bindgroup();
|
self.update_bindgroup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ fn menu_items_from_wrapper(entries: Vec<WrapperMenuItem>) -> Vec<MenuItemKind> {
|
|||||||
}
|
}
|
||||||
WrapperMenuItem::SubMenu { text: name, items, .. } => {
|
WrapperMenuItem::SubMenu { text: name, items, .. } => {
|
||||||
let items = menu_items_from_wrapper(items);
|
let items = menu_items_from_wrapper(items);
|
||||||
let items = items.iter().map(|item| menu_item_kind_to_dyn(item)).collect::<Vec<&dyn IsMenuItem>>();
|
let items = items.iter().map(menu_item_kind_to_dyn).collect::<Vec<&dyn IsMenuItem>>();
|
||||||
let submenu = Submenu::with_items(name, true, &items).unwrap();
|
let submenu = Submenu::with_items(name, true, &items).unwrap();
|
||||||
menu_items.push(MenuItemKind::Submenu(submenu));
|
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() {
|
for item in items.iter() {
|
||||||
menu.remove(menu_item_kind_to_dyn(item)).unwrap();
|
menu.remove(menu_item_kind_to_dyn(item)).unwrap();
|
||||||
}
|
}
|
||||||
let items = new_items.iter().map(|item| menu_item_kind_to_dyn(item)).collect::<Vec<&dyn IsMenuItem>>();
|
let items = new_items.iter().map(menu_item_kind_to_dyn).collect::<Vec<&dyn IsMenuItem>>();
|
||||||
menu.append_items(items.as_ref()).unwrap();
|
menu.append_items(items.as_ref()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageD
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
FrontendMessage::TriggerSaveDocument { document_id, name, path, content } => {
|
FrontendMessage::TriggerSaveDocument { document_id, name, path, content } => {
|
||||||
|
let content = content.into_vec();
|
||||||
if let Some(path) = path {
|
if let Some(path) = path {
|
||||||
dispatcher.respond(DesktopFrontendMessage::WriteFile { path, content });
|
dispatcher.respond(DesktopFrontendMessage::WriteFile { path, content });
|
||||||
} else {
|
} else {
|
||||||
@@ -42,6 +43,7 @@ pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FrontendMessage::TriggerSaveFile { name, content } => {
|
FrontendMessage::TriggerSaveFile { name, content } => {
|
||||||
|
let content = content.into_vec();
|
||||||
dispatcher.respond(DesktopFrontendMessage::SaveFileDialog {
|
dispatcher.respond(DesktopFrontendMessage::SaveFileDialog {
|
||||||
title: "Save File".to_string(),
|
title: "Save File".to_string(),
|
||||||
default_filename: name,
|
default_filename: name,
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ impl DesktopWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum NodeGraphExecutionResult {
|
pub enum NodeGraphExecutionResult {
|
||||||
HasRun(Option<wgpu::Texture>),
|
HasRun(Option<std::sync::Arc<wgpu::Texture>>),
|
||||||
NotRun,
|
NotRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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::input_keyboard::{Key, LabeledKeyOrMouseMotion, LabeledShortcut};
|
||||||
use graphite_editor::messages::input_mapper::utility_types::misc::ActionShortcut;
|
use graphite_editor::messages::input_mapper::utility_types::misc::ActionShortcut;
|
||||||
use graphite_editor::messages::layout::LayoutMessage;
|
use graphite_editor::messages::layout::LayoutMessage;
|
||||||
use graphite_editor::messages::tool::tool_messages::tool_prelude::{Layout, LayoutGroup, LayoutTarget, MenuListEntry, Widget, WidgetId};
|
use graphite_editor::messages::tool::tool_messages::tool_prelude::{Layout, LayoutGroup, LayoutTarget, MenuListEntry, Widget, WidgetId, WidgetRow};
|
||||||
|
|
||||||
use crate::messages::{EditorMessage, KeyCode, MenuItem, Modifiers, Shortcut};
|
use crate::messages::{EditorMessage, KeyCode, MenuItem, Modifiers, Shortcut};
|
||||||
|
|
||||||
@@ -15,11 +15,11 @@ pub(crate) mod menu {
|
|||||||
[layout_group] => layout_group,
|
[layout_group] => layout_group,
|
||||||
_ => panic!("Menu bar layout is supposed to have exactly one layout group"),
|
_ => panic!("Menu bar layout is supposed to have exactly one layout group"),
|
||||||
};
|
};
|
||||||
let LayoutGroup::Row { widgets } = layout_group else {
|
let LayoutGroup::Row(WidgetRow { widgets }) = layout_group else {
|
||||||
panic!("Menu bar layout group is supposed to be a row");
|
panic!("Menu bar layout group is supposed to be a row");
|
||||||
};
|
};
|
||||||
widgets
|
widgets
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|widget| {
|
.map(|widget| {
|
||||||
let text_button = match widget.widget.as_ref() {
|
let text_button = match widget.widget.as_ref() {
|
||||||
Widget::TextButton(text_button) => text_button,
|
Widget::TextButton(text_button) => text_button,
|
||||||
@@ -79,7 +79,7 @@ pub(crate) mod menu {
|
|||||||
let enabled = !*disabled;
|
let enabled = !*disabled;
|
||||||
|
|
||||||
if !children.is_empty() {
|
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 };
|
return MenuItem::SubMenu { id, text, enabled, items };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,8 +88,8 @@ pub(crate) mod menu {
|
|||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
match icon.as_str() {
|
match icon.as_deref() {
|
||||||
"CheckboxChecked" => {
|
Some("CheckboxChecked") => {
|
||||||
return MenuItem::Checkbox {
|
return MenuItem::Checkbox {
|
||||||
id,
|
id,
|
||||||
text,
|
text,
|
||||||
@@ -98,7 +98,7 @@ pub(crate) mod menu {
|
|||||||
checked: true,
|
checked: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
"CheckboxUnchecked" => {
|
Some("CheckboxUnchecked") => {
|
||||||
return MenuItem::Checkbox {
|
return MenuItem::Checkbox {
|
||||||
id,
|
id,
|
||||||
text,
|
text,
|
||||||
|
|||||||
+2
-1
@@ -29,12 +29,13 @@ log = { workspace = true }
|
|||||||
bitflags = { workspace = true }
|
bitflags = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
serde_bytes = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
kurbo = { workspace = true }
|
kurbo = { workspace = true }
|
||||||
futures = { workspace = true }
|
futures = { workspace = true }
|
||||||
glam = { workspace = true }
|
glam = { workspace = true }
|
||||||
derivative = { workspace = true }
|
derivative = { workspace = true }
|
||||||
specta = { workspace = true }
|
tsify = { workspace = true }
|
||||||
dyn-any = { workspace = true }
|
dyn-any = { workspace = true }
|
||||||
num_enum = { workspace = true }
|
num_enum = { workspace = true }
|
||||||
usvg = { workspace = true }
|
usvg = { workspace = true }
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ mod test {
|
|||||||
} = response
|
} = response
|
||||||
{
|
{
|
||||||
if let DiffUpdate::Layout(sub_layout) = &diff[0].new_value {
|
if let DiffUpdate::Layout(sub_layout) = &diff[0].new_value {
|
||||||
if let LayoutGroup::Row { widgets } = &sub_layout.0[0] {
|
if let LayoutGroup::Row(WidgetRow { widgets }) = &sub_layout.0[0] {
|
||||||
if let Widget::TextLabel(TextLabel { value, .. }) = &*widgets[0].widget {
|
if let Widget::TextLabel(TextLabel { value, .. }) = &*widgets[0].widget {
|
||||||
print_problem_to_terminal_on_failure(value);
|
print_problem_to_terminal_on_failure(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
/// 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,7 +3,6 @@ extern crate graphite_proc_macros;
|
|||||||
// `macro_use` puts these macros into scope for all descendant code files
|
// `macro_use` puts these macros into scope for all descendant code files
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
mod generate_ts_types;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
|
|||||||
@@ -11,37 +11,46 @@ impl MessageHandler<AppWindowMessage, ()> for AppWindowMessageHandler {
|
|||||||
fn process_message(&mut self, message: AppWindowMessage, responses: &mut std::collections::VecDeque<Message>, _: ()) {
|
fn process_message(&mut self, message: AppWindowMessage, responses: &mut std::collections::VecDeque<Message>, _: ()) {
|
||||||
match message {
|
match message {
|
||||||
AppWindowMessage::PointerLock => {
|
AppWindowMessage::PointerLock => {
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowPointerLock);
|
responses.add(FrontendMessage::WindowPointerLock);
|
||||||
}
|
}
|
||||||
AppWindowMessage::PointerLockMove { x, y } => {
|
AppWindowMessage::PointerLockMove { x, y } => {
|
||||||
responses.add(FrontendMessage::WindowPointerLockMove { x, y });
|
responses.add(FrontendMessage::WindowPointerLockMove { position: (x, y) });
|
||||||
}
|
}
|
||||||
AppWindowMessage::Close => {
|
AppWindowMessage::Close => {
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowClose);
|
responses.add(FrontendMessage::WindowClose);
|
||||||
}
|
}
|
||||||
AppWindowMessage::Minimize => {
|
AppWindowMessage::Minimize => {
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowMinimize);
|
responses.add(FrontendMessage::WindowMinimize);
|
||||||
}
|
}
|
||||||
AppWindowMessage::Maximize => {
|
AppWindowMessage::Maximize => {
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowMaximize);
|
responses.add(FrontendMessage::WindowMaximize);
|
||||||
}
|
}
|
||||||
AppWindowMessage::Fullscreen => {
|
AppWindowMessage::Fullscreen => {
|
||||||
responses.add(FrontendMessage::WindowFullscreen);
|
responses.add(FrontendMessage::WindowFullscreen);
|
||||||
}
|
}
|
||||||
AppWindowMessage::Drag => {
|
AppWindowMessage::Drag => {
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowDrag);
|
responses.add(FrontendMessage::WindowDrag);
|
||||||
}
|
}
|
||||||
AppWindowMessage::Hide => {
|
AppWindowMessage::Hide => {
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowHide);
|
responses.add(FrontendMessage::WindowHide);
|
||||||
}
|
}
|
||||||
AppWindowMessage::HideOthers => {
|
AppWindowMessage::HideOthers => {
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowHideOthers);
|
responses.add(FrontendMessage::WindowHideOthers);
|
||||||
}
|
}
|
||||||
AppWindowMessage::ShowAll => {
|
AppWindowMessage::ShowAll => {
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowShowAll);
|
responses.add(FrontendMessage::WindowShowAll);
|
||||||
}
|
}
|
||||||
AppWindowMessage::Restart => {
|
AppWindowMessage::Restart => {
|
||||||
responses.add(PortfolioMessage::AutoSaveAllDocuments);
|
responses.add(PortfolioMessage::AutoSaveAllDocuments);
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowRestart);
|
responses.add(FrontendMessage::WindowRestart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +66,8 @@ impl MessageHandler<AppWindowMessage, ()> for AppWindowMessageHandler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Default, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Copy, Default, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum AppWindowPlatform {
|
pub enum AppWindowPlatform {
|
||||||
#[default]
|
#[default]
|
||||||
Web,
|
Web,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ impl DialogLayoutHolder for ExportDialogMessageHandler {
|
|||||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
TextButton::new("Cancel").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
||||||
];
|
];
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +113,7 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
|||||||
.unit("")
|
.unit("")
|
||||||
.min(0.)
|
.min(0.)
|
||||||
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
|
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
|
||||||
|
.increment_step(0.5)
|
||||||
.disabled(self.file_type == FileType::Svg)
|
.disabled(self.file_type == FileType::Svg)
|
||||||
.on_update(|number_input: &NumberInput| ExportDialogMessage::ScaleFactor { factor: number_input.value.unwrap() }.into())
|
.on_update(|number_input: &NumberInput| ExportDialogMessage::ScaleFactor { factor: number_input.value.unwrap() }.into())
|
||||||
.min_width(200)
|
.min_width(200)
|
||||||
@@ -170,10 +171,10 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
|||||||
];
|
];
|
||||||
|
|
||||||
Layout(vec![
|
Layout(vec![
|
||||||
LayoutGroup::Row { widgets: export_type },
|
LayoutGroup::row(export_type),
|
||||||
LayoutGroup::Row { widgets: resolution },
|
LayoutGroup::row(resolution),
|
||||||
LayoutGroup::Row { widgets: export_area },
|
LayoutGroup::row(export_area),
|
||||||
LayoutGroup::Row { widgets: transparent_background },
|
LayoutGroup::row(transparent_background),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -71,7 +71,7 @@ impl DialogLayoutHolder for NewDocumentDialogMessageHandler {
|
|||||||
TextButton::new("Cancel").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
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(),
|
.widget_instance(),
|
||||||
];
|
];
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets: name }, LayoutGroup::Row { widgets: infinite }, LayoutGroup::Row { widgets: scale }])
|
Layout(vec![LayoutGroup::row(name), LayoutGroup::row(infinite), LayoutGroup::row(scale)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+37
-2
@@ -387,9 +387,44 @@ impl PreferencesDialogMessageHandler {
|
|||||||
|
|
||||||
rows.push(ui_acceleration);
|
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(|r| LayoutGroup::Row { widgets: r }).collect())
|
Layout(rows.into_iter().map(LayoutGroup::row).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_layout(&self, responses: &mut VecDeque<Message>, layout_target: LayoutTarget, preferences: &PreferencesMessageHandler) {
|
pub fn send_layout(&self, responses: &mut VecDeque<Message>, layout_target: LayoutTarget, preferences: &PreferencesMessageHandler) {
|
||||||
@@ -416,7 +451,7 @@ impl PreferencesDialogMessageHandler {
|
|||||||
TextButton::new("Reset to Defaults").on_update(|_| PreferencesMessage::ResetToDefaults.into()).widget_instance(),
|
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) {
|
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 {
|
fn layout_buttons(&self) -> Layout {
|
||||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
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 {
|
fn layout_column_2(&self) -> Layout {
|
||||||
@@ -29,7 +29,7 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(icon, label, url)| {
|
.map(|(icon, label, url)| {
|
||||||
TextButton::new(label)
|
TextButton::new(label)
|
||||||
.icon(Some(icon.into()))
|
.icon(icon)
|
||||||
.flush(true)
|
.flush(true)
|
||||||
.on_update(|_| FrontendMessage::TriggerVisitLink { url: url.into() }.into())
|
.on_update(|_| FrontendMessage::TriggerVisitLink { url: url.into() }.into())
|
||||||
.widget_instance()
|
.widget_instance()
|
||||||
@@ -40,7 +40,7 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
|||||||
let localized_commit_year = self.localized_commit_year.clone();
|
let localized_commit_year = self.localized_commit_year.clone();
|
||||||
widgets.push(
|
widgets.push(
|
||||||
TextButton::new("Licenses")
|
TextButton::new("Licenses")
|
||||||
.icon(Some("License".into()))
|
.icon("License")
|
||||||
.flush(true)
|
.flush(true)
|
||||||
.on_update(move |_| {
|
.on_update(move |_| {
|
||||||
DialogMessage::RequestLicensesDialogWithLocalizedCommitDate {
|
DialogMessage::RequestLicensesDialogWithLocalizedCommitDate {
|
||||||
@@ -51,22 +51,16 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
|
|||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Column { widgets }])
|
Layout(vec![LayoutGroup::column(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutHolder for AboutGraphiteDialog {
|
impl LayoutHolder for AboutGraphiteDialog {
|
||||||
fn layout(&self) -> Layout {
|
fn layout(&self) -> Layout {
|
||||||
Layout(vec![
|
Layout(vec![
|
||||||
LayoutGroup::Row {
|
LayoutGroup::row(vec![TextLabel::new("About this release").bold(true).widget_instance()]),
|
||||||
widgets: 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(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(),
|
TextButton::new("Cancel").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
||||||
];
|
];
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,12 +33,8 @@ impl LayoutHolder for CloseAllDocumentsDialog {
|
|||||||
let unsaved_list = "• ".to_string() + &self.unsaved_document_names.join("\n• ");
|
let unsaved_list = "• ".to_string() + &self.unsaved_document_names.join("\n• ");
|
||||||
|
|
||||||
Layout(vec![
|
Layout(vec![
|
||||||
LayoutGroup::Row {
|
LayoutGroup::row(vec![TextLabel::new("Save documents before closing them?").bold(true).multiline(true).widget_instance()]),
|
||||||
widgets: 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(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(),
|
TextButton::new("Cancel").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
||||||
];
|
];
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,12 +52,8 @@ impl LayoutHolder for CloseDocumentDialog {
|
|||||||
let break_lines = if self.document_name.len() > max_one_line_length { '\n' } else { ' ' };
|
let break_lines = if self.document_name.len() > max_one_line_length { '\n' } else { ' ' };
|
||||||
|
|
||||||
Layout(vec![
|
Layout(vec![
|
||||||
LayoutGroup::Row {
|
LayoutGroup::row(vec![TextLabel::new("Save document before closing it?").bold(true).widget_instance()]),
|
||||||
widgets: 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(format!("\"{name}{ellipsis}\"{break_lines}has unsaved changes")).multiline(true).widget_instance()],
|
|
||||||
},
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ impl DialogLayoutHolder for ConfirmRestartDialog {
|
|||||||
TextButton::new("Later").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
TextButton::new("Later").on_update(|_| FrontendMessage::DialogClose.into()).widget_instance(),
|
||||||
];
|
];
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,27 +33,23 @@ impl LayoutHolder for ConfirmRestartDialog {
|
|||||||
let changed_settings = "• ".to_string() + &self.changed_settings.join("\n• ");
|
let changed_settings = "• ".to_string() + &self.changed_settings.join("\n• ");
|
||||||
|
|
||||||
Layout(vec![
|
Layout(vec![
|
||||||
LayoutGroup::Row {
|
LayoutGroup::row(vec![TextLabel::new("Restart to apply changes?").bold(true).multiline(true).widget_instance()]),
|
||||||
widgets: vec![TextLabel::new("Restart to apply changes?").bold(true).multiline(true).widget_instance()],
|
LayoutGroup::row(vec![
|
||||||
},
|
TextLabel::new(
|
||||||
LayoutGroup::Row {
|
format!(
|
||||||
widgets: vec![
|
"
|
||||||
TextLabel::new(
|
|
||||||
format!(
|
|
||||||
"
|
|
||||||
Settings that only take effect on next launch:\n\
|
Settings that only take effect on next launch:\n\
|
||||||
{changed_settings}\n\
|
{changed_settings}\n\
|
||||||
\n\
|
\n\
|
||||||
This only takes a few seconds. Open documents,\n\
|
This only takes a few seconds. Open documents,\n\
|
||||||
even unsaved ones, will be automatically restored.
|
even unsaved ones, will be automatically restored.
|
||||||
"
|
"
|
||||||
)
|
|
||||||
.trim(),
|
|
||||||
)
|
)
|
||||||
.multiline(true)
|
.trim(),
|
||||||
.widget_instance(),
|
)
|
||||||
],
|
.multiline(true)
|
||||||
},
|
.widget_instance(),
|
||||||
|
]),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ impl DialogLayoutHolder for DemoArtworkDialog {
|
|||||||
fn layout_buttons(&self) -> Layout {
|
fn layout_buttons(&self) -> Layout {
|
||||||
let widgets = vec![TextButton::new("Close").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
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
|
let images = chunk
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(name, thumbnail, filename)| ImageButton::new(*thumbnail).width(Some("256px".into())).on_update(|_| make_dialog(name, filename)).widget_instance())
|
.map(|(name, thumbnail, filename)| ImageButton::new(*thumbnail).width("256px").on_update(|_| make_dialog(name, filename)).widget_instance())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let buttons = chunk
|
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())
|
.map(|(name, _, filename)| TextButton::new(*name).min_width(256).flush(true).on_update(|_| make_dialog(name, filename)).widget_instance())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
vec![LayoutGroup::Row { widgets: images }, LayoutGroup::Row { widgets: buttons }, LayoutGroup::Row { widgets: vec![] }]
|
vec![LayoutGroup::row(images), LayoutGroup::row(buttons), LayoutGroup::row(vec![])]
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let _ = rows_of_images_with_buttons.pop();
|
let _ = rows_of_images_with_buttons.pop();
|
||||||
|
|||||||
@@ -14,19 +14,15 @@ impl DialogLayoutHolder for ErrorDialog {
|
|||||||
fn layout_buttons(&self) -> Layout {
|
fn layout_buttons(&self) -> Layout {
|
||||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
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 {
|
impl LayoutHolder for ErrorDialog {
|
||||||
fn layout(&self) -> Layout {
|
fn layout(&self) -> Layout {
|
||||||
Layout(vec![
|
Layout(vec![
|
||||||
LayoutGroup::Row {
|
LayoutGroup::row(vec![TextLabel::new(&self.title).bold(true).widget_instance()]),
|
||||||
widgets: 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.description).multiline(true).widget_instance()],
|
|
||||||
},
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ impl DialogLayoutHolder for LicensesDialog {
|
|||||||
fn layout_buttons(&self) -> Layout {
|
fn layout_buttons(&self) -> Layout {
|
||||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
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 {
|
fn layout_column_2(&self) -> Layout {
|
||||||
@@ -34,10 +34,10 @@ impl DialogLayoutHolder for LicensesDialog {
|
|||||||
];
|
];
|
||||||
let widgets = button_definitions
|
let widgets = button_definitions
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(icon, label, message_factory)| TextButton::new(label).icon(Some((icon).into())).flush(true).on_update(move |_| message_factory()).widget_instance())
|
.map(|&(icon, label, message_factory)| TextButton::new(label).icon(icon).flush(true).on_update(move |_| message_factory()).widget_instance())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Column { widgets }])
|
Layout(vec![LayoutGroup::column(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,12 +56,8 @@ impl LayoutHolder for LicensesDialog {
|
|||||||
let description = description.trim();
|
let description = description.trim();
|
||||||
|
|
||||||
Layout(vec![
|
Layout(vec![
|
||||||
LayoutGroup::Row {
|
LayoutGroup::row(vec![TextLabel::new("Graphite is free, open source software").bold(true).widget_instance()]),
|
||||||
widgets: 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(description).multiline(true).widget_instance()],
|
|
||||||
},
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ impl DialogLayoutHolder for LicensesThirdPartyDialog {
|
|||||||
fn layout_buttons(&self) -> Layout {
|
fn layout_buttons(&self) -> Layout {
|
||||||
let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()];
|
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,14 +31,12 @@ 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
|
// 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;
|
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 {
|
Layout(vec![LayoutGroup::row(vec![
|
||||||
widgets: vec![
|
TextLabel::new(license_text)
|
||||||
TextLabel::new(license_text)
|
.monospace(true)
|
||||||
.monospace(true)
|
.multiline(true)
|
||||||
.multiline(true)
|
.min_width_characters(non_wrapping_column_width)
|
||||||
.min_width_characters(non_wrapping_column_width)
|
.widget_instance(),
|
||||||
.widget_instance(),
|
])])
|
||||||
],
|
|
||||||
}])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
use super::IconName;
|
||||||
use super::utility_types::{DocumentDetails, MouseCursorIcon, OpenDocument};
|
use super::utility_types::{DocumentDetails, MouseCursorIcon, OpenDocument};
|
||||||
use crate::messages::app_window::app_window_message_handler::AppWindowPlatform;
|
use crate::messages::app_window::app_window_message_handler::AppWindowPlatform;
|
||||||
use crate::messages::frontend::utility_types::EyedropperPreviewImage;
|
use crate::messages::frontend::utility_types::EyedropperPreviewImage;
|
||||||
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
||||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||||
use crate::messages::portfolio::document::node_graph::utility_types::{
|
use crate::messages::portfolio::document::node_graph::utility_types::{
|
||||||
BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendGraphInput, FrontendGraphOutput, FrontendNode, FrontendNodeType, NodeGraphErrorDiagnostic, Transform,
|
BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendGraphInput, FrontendGraphOutput, FrontendNode, FrontendNodeType, NodeGraphErrorDiagnostic,
|
||||||
};
|
};
|
||||||
use crate::messages::portfolio::document::utility_types::nodes::{LayerPanelEntry, LayerStructureEntry};
|
use crate::messages::portfolio::document::utility_types::nodes::{LayerPanelEntry, LayerStructureEntry};
|
||||||
use crate::messages::portfolio::document::utility_types::wires::{WirePath, WirePathUpdate};
|
use crate::messages::portfolio::document::utility_types::wires::{WirePath, WirePathUpdate};
|
||||||
use crate::messages::prelude::*;
|
use crate::messages::prelude::*;
|
||||||
use glam::IVec2;
|
use crate::messages::tool::tool_messages::eyedropper_tool::PrimarySecondary;
|
||||||
use graph_craft::document::NodeId;
|
use graph_craft::document::NodeId;
|
||||||
use graphene_std::raster::Image;
|
use graphene_std::raster::Image;
|
||||||
use graphene_std::raster::color::Color;
|
use graphene_std::raster::color::Color;
|
||||||
@@ -20,13 +21,14 @@ use std::path::PathBuf;
|
|||||||
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
||||||
|
|
||||||
#[impl_message(Message, Frontend)]
|
#[impl_message(Message, Frontend)]
|
||||||
#[derive(derivative::Derivative, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(derivative::Derivative, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub enum FrontendMessage {
|
pub enum FrontendMessage {
|
||||||
// Display prefix: make the frontend show something, like a dialog
|
// Display prefix: make the frontend show something, like a dialog
|
||||||
DisplayDialog {
|
DisplayDialog {
|
||||||
title: String,
|
title: String,
|
||||||
icon: String,
|
icon: IconName,
|
||||||
},
|
},
|
||||||
DialogClose,
|
DialogClose,
|
||||||
DisplayDialogPanic {
|
DisplayDialogPanic {
|
||||||
@@ -41,7 +43,7 @@ pub enum FrontendMessage {
|
|||||||
font_size: f64,
|
font_size: f64,
|
||||||
color: String,
|
color: String,
|
||||||
#[serde(rename = "fontData")]
|
#[serde(rename = "fontData")]
|
||||||
font_data: Vec<u8>,
|
font_data: serde_bytes::ByteBuf,
|
||||||
transform: [f64; 6],
|
transform: [f64; 6],
|
||||||
#[serde(rename = "maxWidth")]
|
#[serde(rename = "maxWidth")]
|
||||||
max_width: Option<f64>,
|
max_width: Option<f64>,
|
||||||
@@ -51,7 +53,7 @@ pub enum FrontendMessage {
|
|||||||
},
|
},
|
||||||
DisplayEditableTextboxUpdateFontData {
|
DisplayEditableTextboxUpdateFontData {
|
||||||
#[serde(rename = "fontData")]
|
#[serde(rename = "fontData")]
|
||||||
font_data: Vec<u8>,
|
font_data: serde_bytes::ByteBuf,
|
||||||
},
|
},
|
||||||
DisplayEditableTextboxTransform {
|
DisplayEditableTextboxTransform {
|
||||||
transform: [f64; 6],
|
transform: [f64; 6],
|
||||||
@@ -87,11 +89,11 @@ pub enum FrontendMessage {
|
|||||||
document_id: DocumentId,
|
document_id: DocumentId,
|
||||||
name: String,
|
name: String,
|
||||||
path: Option<PathBuf>,
|
path: Option<PathBuf>,
|
||||||
content: Vec<u8>,
|
content: serde_bytes::ByteBuf,
|
||||||
},
|
},
|
||||||
TriggerSaveFile {
|
TriggerSaveFile {
|
||||||
name: String,
|
name: String,
|
||||||
content: Vec<u8>,
|
content: serde_bytes::ByteBuf,
|
||||||
},
|
},
|
||||||
TriggerExportImage {
|
TriggerExportImage {
|
||||||
svg: String,
|
svg: String,
|
||||||
@@ -125,6 +127,7 @@ pub enum FrontendMessage {
|
|||||||
TriggerOpen,
|
TriggerOpen,
|
||||||
TriggerImport,
|
TriggerImport,
|
||||||
TriggerSavePreferences {
|
TriggerSavePreferences {
|
||||||
|
#[tsify(type = "unknown")]
|
||||||
preferences: PreferencesMessageHandler,
|
preferences: PreferencesMessageHandler,
|
||||||
},
|
},
|
||||||
TriggerSaveActiveDocument {
|
TriggerSaveActiveDocument {
|
||||||
@@ -152,9 +155,8 @@ pub enum FrontendMessage {
|
|||||||
document_id: DocumentId,
|
document_id: DocumentId,
|
||||||
},
|
},
|
||||||
UpdateGradientStopColorPickerPosition {
|
UpdateGradientStopColorPickerPosition {
|
||||||
color: Color,
|
color: Color, // TODO: Color (without `none`) -> Color (with `none`)
|
||||||
x: f64,
|
position: (f64, f64),
|
||||||
y: f64,
|
|
||||||
},
|
},
|
||||||
UpdateImportsExports {
|
UpdateImportsExports {
|
||||||
/// If the primary import is not visible, then it is None.
|
/// If the primary import is not visible, then it is None.
|
||||||
@@ -163,10 +165,10 @@ pub enum FrontendMessage {
|
|||||||
exports: Vec<Option<FrontendGraphInput>>,
|
exports: Vec<Option<FrontendGraphInput>>,
|
||||||
/// The primary import location.
|
/// The primary import location.
|
||||||
#[serde(rename = "importPosition")]
|
#[serde(rename = "importPosition")]
|
||||||
import_position: IVec2,
|
import_position: (i32, i32),
|
||||||
/// The primary export location.
|
/// The primary export location.
|
||||||
#[serde(rename = "exportPosition")]
|
#[serde(rename = "exportPosition")]
|
||||||
export_position: IVec2,
|
export_position: (i32, i32),
|
||||||
/// The document network does not have an add import or export button.
|
/// The document network does not have an add import or export button.
|
||||||
#[serde(rename = "addImportExport")]
|
#[serde(rename = "addImportExport")]
|
||||||
add_import_export: bool,
|
add_import_export: bool,
|
||||||
@@ -202,7 +204,7 @@ pub enum FrontendMessage {
|
|||||||
UpdateLayout {
|
UpdateLayout {
|
||||||
#[serde(rename = "layoutTarget")]
|
#[serde(rename = "layoutTarget")]
|
||||||
layout_target: LayoutTarget,
|
layout_target: LayoutTarget,
|
||||||
diff: Vec<WidgetDiff>,
|
diff: Vec<WidgetDiff>, // TODO: Align this with what's generated
|
||||||
},
|
},
|
||||||
UpdateImportReorderIndex {
|
UpdateImportReorderIndex {
|
||||||
#[serde(rename = "importIndex")]
|
#[serde(rename = "importIndex")]
|
||||||
@@ -253,7 +255,7 @@ pub enum FrontendMessage {
|
|||||||
#[serde(rename = "secondaryColor")]
|
#[serde(rename = "secondaryColor")]
|
||||||
secondary_color: String,
|
secondary_color: String,
|
||||||
#[serde(rename = "setColorChoice")]
|
#[serde(rename = "setColorChoice")]
|
||||||
set_color_choice: Option<String>,
|
set_color_choice: Option<PrimarySecondary>,
|
||||||
},
|
},
|
||||||
UpdateGraphFadeArtwork {
|
UpdateGraphFadeArtwork {
|
||||||
percentage: f64,
|
percentage: f64,
|
||||||
@@ -278,7 +280,8 @@ pub enum FrontendMessage {
|
|||||||
selected: Vec<NodeId>,
|
selected: Vec<NodeId>,
|
||||||
},
|
},
|
||||||
UpdateNodeGraphTransform {
|
UpdateNodeGraphTransform {
|
||||||
transform: Transform,
|
translation: (f64, f64),
|
||||||
|
scale: f64,
|
||||||
},
|
},
|
||||||
UpdateNodeThumbnail {
|
UpdateNodeThumbnail {
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
@@ -304,6 +307,7 @@ pub enum FrontendMessage {
|
|||||||
UpdateViewportHolePunch {
|
UpdateViewportHolePunch {
|
||||||
active: bool,
|
active: bool,
|
||||||
},
|
},
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
UpdateViewportPhysicalBounds {
|
UpdateViewportPhysicalBounds {
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
@@ -322,18 +326,26 @@ pub enum FrontendMessage {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Window prefix: cause the application window to do something
|
// Window prefix: cause the application window to do something
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowPointerLock,
|
WindowPointerLock,
|
||||||
WindowPointerLockMove {
|
WindowPointerLockMove {
|
||||||
x: f64,
|
position: (f64, f64),
|
||||||
y: f64,
|
|
||||||
},
|
},
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowClose,
|
WindowClose,
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowMinimize,
|
WindowMinimize,
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowMaximize,
|
WindowMaximize,
|
||||||
WindowFullscreen,
|
WindowFullscreen,
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowDrag,
|
WindowDrag,
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowHide,
|
WindowHide,
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowHideOthers,
|
WindowHideOthers,
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowShowAll,
|
WindowShowAll,
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowRestart,
|
WindowRestart,
|
||||||
}
|
}
|
||||||
@@ -4,3 +4,7 @@ pub mod utility_types;
|
|||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use frontend_message::{FrontendMessage, FrontendMessageDiscriminant};
|
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,13 +3,15 @@ use std::path::PathBuf;
|
|||||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||||
use crate::messages::prelude::*;
|
use crate::messages::prelude::*;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct OpenDocument {
|
pub struct OpenDocument {
|
||||||
pub id: DocumentId,
|
pub id: DocumentId,
|
||||||
pub details: DocumentDetails,
|
pub details: DocumentDetails,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct DocumentDetails {
|
pub struct DocumentDetails {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub path: Option<PathBuf>,
|
pub path: Option<PathBuf>,
|
||||||
@@ -19,7 +21,8 @@ pub struct DocumentDetails {
|
|||||||
pub is_auto_saved: bool,
|
pub is_auto_saved: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum MouseCursorIcon {
|
pub enum MouseCursorIcon {
|
||||||
#[default]
|
#[default]
|
||||||
Default,
|
Default,
|
||||||
@@ -37,7 +40,8 @@ pub enum MouseCursorIcon {
|
|||||||
Rotate,
|
Rotate,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum FileType {
|
pub enum FileType {
|
||||||
#[default]
|
#[default]
|
||||||
Png,
|
Png,
|
||||||
@@ -55,7 +59,8 @@ impl FileType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ExportBounds {
|
pub enum ExportBounds {
|
||||||
#[default]
|
#[default]
|
||||||
AllArtwork,
|
AllArtwork,
|
||||||
@@ -63,9 +68,10 @@ pub enum ExportBounds {
|
|||||||
Artboard(LayerNodeIdentifier),
|
Artboard(LayerNodeIdentifier),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||||
|
#[derive(Clone, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct EyedropperPreviewImage {
|
pub struct EyedropperPreviewImage {
|
||||||
pub data: Vec<u8>,
|
pub data: serde_bytes::ByteBuf,
|
||||||
pub width: u32,
|
pub width: u32,
|
||||||
pub height: u32,
|
pub height: u32,
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,8 @@ 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
|
// (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 `+`.
|
// 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)]
|
#[impl_message(Message, InputMapperMessage, KeyDown)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type, num_enum::TryFromPrimitive)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, num_enum::TryFromPrimitive)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Key {
|
pub enum Key {
|
||||||
// Writing system keys
|
// Writing system keys
|
||||||
@@ -379,7 +380,8 @@ impl fmt::Display for KeysGroup {
|
|||||||
// LabeledKey
|
// LabeledKey
|
||||||
// ==========
|
// ==========
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct LabeledKey {
|
pub struct LabeledKey {
|
||||||
key: Key,
|
key: Key,
|
||||||
label: String,
|
label: String,
|
||||||
@@ -395,7 +397,8 @@ impl LabeledKey {
|
|||||||
// MouseMotion
|
// MouseMotion
|
||||||
// ===========
|
// ===========
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum MouseMotion {
|
pub enum MouseMotion {
|
||||||
None,
|
None,
|
||||||
Lmb,
|
Lmb,
|
||||||
@@ -415,7 +418,8 @@ pub enum MouseMotion {
|
|||||||
// LabeledKeyOrMouseMotion
|
// LabeledKeyOrMouseMotion
|
||||||
// =======================
|
// =======================
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum LabeledKeyOrMouseMotion {
|
pub enum LabeledKeyOrMouseMotion {
|
||||||
Key(LabeledKey),
|
Key(LabeledKey),
|
||||||
@@ -437,7 +441,8 @@ impl From<Key> for LabeledKeyOrMouseMotion {
|
|||||||
// LabeledShortcut
|
// LabeledShortcut
|
||||||
// ===============
|
// ===============
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct LabeledShortcut(pub Vec<LabeledKeyOrMouseMotion>);
|
pub struct LabeledShortcut(pub Vec<LabeledKeyOrMouseMotion>);
|
||||||
|
|
||||||
impl From<KeysGroup> for LabeledShortcut {
|
impl From<KeysGroup> for LabeledShortcut {
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ bitflags! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, InputMapperMessage, DoubleClick)]
|
#[impl_message(Message, InputMapperMessage, DoubleClick)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type, num_enum::TryFromPrimitive)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, num_enum::TryFromPrimitive)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum MouseButton {
|
pub enum MouseButton {
|
||||||
Left,
|
Left,
|
||||||
|
|||||||
@@ -106,8 +106,10 @@ pub struct MappingEntry {
|
|||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ActionShortcut {
|
pub enum ActionShortcut {
|
||||||
|
#[serde(skip)]
|
||||||
Action(MessageDiscriminant),
|
Action(MessageDiscriminant),
|
||||||
#[serde(rename = "shortcut")]
|
#[serde(rename = "shortcut")]
|
||||||
Shortcut(LabeledShortcut),
|
Shortcut(LabeledShortcut),
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
use crate::messages::input_mapper::utility_types::input_keyboard::KeysGroup;
|
use crate::messages::input_mapper::utility_types::input_keyboard::KeysGroup;
|
||||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||||
use crate::messages::prelude::*;
|
use crate::messages::prelude::*;
|
||||||
use graphene_std::raster::color::Color;
|
use graphene_std::vector::style::FillChoice;
|
||||||
use graphene_std::vector::style::{FillChoice, GradientStop, GradientStops};
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ impl LayoutMessageHandler {
|
|||||||
while let Some((mut widget_path, layout_group)) = stack.pop() {
|
while let Some((mut widget_path, layout_group)) = stack.pop() {
|
||||||
match layout_group {
|
match layout_group {
|
||||||
// Check if any of the widgets in the current column or row have the correct id
|
// Check if any of the widgets in the current column or row have the correct id
|
||||||
LayoutGroup::Column { widgets } | LayoutGroup::Row { widgets } => {
|
LayoutGroup::Column(WidgetColumn { widgets }) | LayoutGroup::Row(WidgetRow { widgets }) => {
|
||||||
for (index, widget) in widgets.iter().enumerate() {
|
for (index, widget) in widgets.iter().enumerate() {
|
||||||
// Return if this is the correct ID
|
// Return if this is the correct ID
|
||||||
if widget.widget_id == widget_id {
|
if widget.widget_id == widget_id {
|
||||||
@@ -84,10 +83,10 @@ impl LayoutMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// A section contains more LayoutGroups which we add to the stack.
|
// A section contains more LayoutGroups which we add to the stack.
|
||||||
LayoutGroup::Section { layout, .. } => {
|
LayoutGroup::Section(WidgetSection { layout, .. }) => {
|
||||||
stack.extend(layout.0.iter().enumerate().map(|(index, val)| ([widget_path.as_slice(), &[index]].concat(), val)));
|
stack.extend(layout.0.iter().enumerate().map(|(index, val)| ([widget_path.as_slice(), &[index]].concat(), val)));
|
||||||
}
|
}
|
||||||
LayoutGroup::Table { rows, .. } => {
|
LayoutGroup::Table(WidgetTable { rows, .. }) => {
|
||||||
for (row_index, row) in rows.iter().enumerate() {
|
for (row_index, row) in rows.iter().enumerate() {
|
||||||
for (cell_index, cell) in row.iter().enumerate() {
|
for (cell_index, cell) in row.iter().enumerate() {
|
||||||
// Return if this is the correct ID
|
// Return if this is the correct ID
|
||||||
@@ -158,60 +157,12 @@ impl LayoutMessageHandler {
|
|||||||
let callback_message = match action {
|
let callback_message = match action {
|
||||||
WidgetValueAction::Commit => (color_button.on_commit.callback)(&()),
|
WidgetValueAction::Commit => (color_button.on_commit.callback)(&()),
|
||||||
WidgetValueAction::Update => {
|
WidgetValueAction::Update => {
|
||||||
// Decodes the colors in gamma, not linear
|
let Ok(fill_choice) = serde_json::from_value::<FillChoice>(value) else {
|
||||||
let decode_color = |color: &serde_json::map::Map<String, serde_json::value::Value>| -> Option<Color> {
|
warn!("ColorInput update was not able to be parsed as FillChoice: {color_button:?}");
|
||||||
let red = color.get("red").and_then(|x| x.as_f64()).map(|x| x as f32);
|
return;
|
||||||
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,7 +10,8 @@ use std::hash::{Hash, Hasher};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[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)]
|
||||||
pub struct WidgetId(pub u64);
|
pub struct WidgetId(pub u64);
|
||||||
|
|
||||||
impl core::fmt::Display for WidgetId {
|
impl core::fmt::Display for WidgetId {
|
||||||
@@ -19,7 +20,8 @@ impl core::fmt::Display for WidgetId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug, Hash, Eq, Copy, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, Hash, Eq, Copy, serde::Serialize, serde::Deserialize)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum LayoutTarget {
|
pub enum LayoutTarget {
|
||||||
/// The spreadsheet panel allows for the visualisation of data in the graph.
|
/// The spreadsheet panel allows for the visualisation of data in the graph.
|
||||||
@@ -59,6 +61,7 @@ pub enum LayoutTarget {
|
|||||||
|
|
||||||
// KEEP THIS ENUM LAST
|
// KEEP THIS ENUM LAST
|
||||||
// This is a marker that is used to define an array that is used to hold widgets
|
// This is a marker that is used to define an array that is used to hold widgets
|
||||||
|
#[serde(skip)]
|
||||||
_LayoutTargetLength,
|
_LayoutTargetLength,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +154,8 @@ fn compute_checkbox_id(layout_target: LayoutTarget, widget_path: &[usize], widge
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Contains an arrangement of widgets mounted somewhere specific in the frontend.
|
/// Contains an arrangement of widgets mounted somewhere specific in the frontend.
|
||||||
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize, PartialEq, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize, PartialEq)]
|
||||||
pub struct Layout(pub Vec<LayoutGroup>);
|
pub struct Layout(pub Vec<LayoutGroup>);
|
||||||
|
|
||||||
impl Layout {
|
impl Layout {
|
||||||
@@ -241,19 +245,19 @@ impl<'a> Iterator for WidgetIter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Some(LayoutGroup::Column { widgets }) => {
|
Some(LayoutGroup::Column(WidgetColumn { widgets })) => {
|
||||||
self.current_slice = Some(widgets);
|
self.current_slice = Some(widgets);
|
||||||
self.next()
|
self.next()
|
||||||
}
|
}
|
||||||
Some(LayoutGroup::Row { widgets }) => {
|
Some(LayoutGroup::Row(WidgetRow { widgets })) => {
|
||||||
self.current_slice = Some(widgets);
|
self.current_slice = Some(widgets);
|
||||||
self.next()
|
self.next()
|
||||||
}
|
}
|
||||||
Some(LayoutGroup::Table { rows, .. }) => {
|
Some(LayoutGroup::Table(WidgetTable { rows, .. })) => {
|
||||||
self.table.extend(rows.iter().flatten().rev());
|
self.table.extend(rows.iter().flatten().rev());
|
||||||
self.next()
|
self.next()
|
||||||
}
|
}
|
||||||
Some(LayoutGroup::Section { layout, .. }) => {
|
Some(LayoutGroup::Section(WidgetSection { layout, .. })) => {
|
||||||
for layout_row in &layout.0 {
|
for layout_row in &layout.0 {
|
||||||
self.stack.push(layout_row);
|
self.stack.push(layout_row);
|
||||||
}
|
}
|
||||||
@@ -293,19 +297,19 @@ impl<'a> Iterator for WidgetIterMut<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Some(LayoutGroup::Column { widgets }) => {
|
Some(LayoutGroup::Column(WidgetColumn { widgets })) => {
|
||||||
self.current_slice = Some(widgets);
|
self.current_slice = Some(widgets);
|
||||||
self.next()
|
self.next()
|
||||||
}
|
}
|
||||||
Some(LayoutGroup::Row { widgets }) => {
|
Some(LayoutGroup::Row(WidgetRow { widgets })) => {
|
||||||
self.current_slice = Some(widgets);
|
self.current_slice = Some(widgets);
|
||||||
self.next()
|
self.next()
|
||||||
}
|
}
|
||||||
Some(LayoutGroup::Table { rows, .. }) => {
|
Some(LayoutGroup::Table(WidgetTable { rows, .. })) => {
|
||||||
self.table.extend(rows.iter_mut().flatten().rev());
|
self.table.extend(rows.iter_mut().flatten().rev());
|
||||||
self.next()
|
self.next()
|
||||||
}
|
}
|
||||||
Some(LayoutGroup::Section { layout, .. }) => {
|
Some(LayoutGroup::Section(WidgetSection { layout, .. })) => {
|
||||||
for layout_row in &mut layout.0 {
|
for layout_row in &mut layout.0 {
|
||||||
self.stack.push(layout_row);
|
self.stack.push(layout_row);
|
||||||
}
|
}
|
||||||
@@ -316,52 +320,88 @@ impl<'a> Iterator for WidgetIterMut<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum LayoutGroup {
|
pub enum LayoutGroup {
|
||||||
#[serde(rename = "column")]
|
Column(WidgetColumn),
|
||||||
Column {
|
Row(WidgetRow),
|
||||||
#[serde(rename = "columnWidgets")]
|
Table(WidgetTable),
|
||||||
widgets: Vec<WidgetInstance>,
|
Section(WidgetSection),
|
||||||
},
|
}
|
||||||
#[serde(rename = "row")]
|
|
||||||
Row {
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
#[serde(rename = "rowWidgets")]
|
#[derive(Default, Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
widgets: Vec<WidgetInstance>,
|
pub struct WidgetColumn {
|
||||||
},
|
#[serde(rename = "columnWidgets")]
|
||||||
#[serde(rename = "table")]
|
pub widgets: Vec<WidgetInstance>,
|
||||||
Table {
|
}
|
||||||
#[serde(rename = "tableWidgets")]
|
|
||||||
rows: Vec<Vec<WidgetInstance>>,
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
unstyled: bool,
|
#[derive(Default, Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
},
|
pub struct WidgetRow {
|
||||||
#[serde(rename = "section")]
|
#[serde(rename = "rowWidgets")]
|
||||||
Section {
|
pub widgets: Vec<WidgetInstance>,
|
||||||
name: String,
|
}
|
||||||
description: String,
|
|
||||||
visible: bool,
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
pinned: bool,
|
#[derive(Default, Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
id: u64,
|
pub struct WidgetTable {
|
||||||
layout: Layout,
|
#[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,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for LayoutGroup {
|
impl Default for LayoutGroup {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::Row { widgets: Vec::new() }
|
Self::Row(Default::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<Vec<WidgetInstance>> for LayoutGroup {
|
impl From<Vec<WidgetInstance>> for LayoutGroup {
|
||||||
fn from(widgets: Vec<WidgetInstance>) -> LayoutGroup {
|
fn from(widgets: Vec<WidgetInstance>) -> LayoutGroup {
|
||||||
LayoutGroup::Row { widgets }
|
LayoutGroup::Row(WidgetRow { widgets })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutGroup {
|
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.
|
/// 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 {
|
pub fn with_tooltip_description(self, description: impl Into<String>) -> Self {
|
||||||
let (is_col, mut widgets) = match self {
|
let (is_col, mut widgets) = match self {
|
||||||
LayoutGroup::Column { widgets } => (true, widgets),
|
LayoutGroup::Column(WidgetColumn { widgets }) => (true, widgets),
|
||||||
LayoutGroup::Row { widgets } => (false, widgets),
|
LayoutGroup::Row(WidgetRow { widgets }) => (false, widgets),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
};
|
};
|
||||||
let description = description.into();
|
let description = description.into();
|
||||||
@@ -394,7 +434,7 @@ impl LayoutGroup {
|
|||||||
val.clone_from(&description);
|
val.clone_from(&description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if is_col { Self::Column { widgets } } else { Self::Row { widgets } }
|
if is_col { Self::Column(WidgetColumn { widgets }) } else { Self::Row(WidgetRow { widgets }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_mut(&mut self) -> WidgetIterMut<'_> {
|
pub fn iter_mut(&mut self) -> WidgetIterMut<'_> {
|
||||||
@@ -413,7 +453,8 @@ impl Diffable for LayoutGroup {
|
|||||||
fn diff(&mut self, new: Self, widget_path: &mut Vec<usize>, widget_diffs: &mut Vec<WidgetDiff>) {
|
fn diff(&mut self, new: Self, widget_path: &mut Vec<usize>, widget_diffs: &mut Vec<WidgetDiff>) {
|
||||||
let is_column = matches!(new, Self::Column { .. });
|
let is_column = matches!(new, Self::Column { .. });
|
||||||
match (self, new) {
|
match (self, new) {
|
||||||
(Self::Column { widgets: current_widgets }, Self::Column { widgets: new_widgets }) | (Self::Row { widgets: current_widgets }, Self::Row { widgets: new_widgets }) => {
|
(Self::Column(WidgetColumn { widgets: current_widgets }), Self::Column(WidgetColumn { widgets: new_widgets }))
|
||||||
|
| (Self::Row(WidgetRow { widgets: current_widgets }), Self::Row(WidgetRow { widgets: new_widgets })) => {
|
||||||
// If the lengths are different then resend the entire panel
|
// If the lengths are different then resend the entire panel
|
||||||
// TODO: Diff insersion and deletion of items
|
// TODO: Diff insersion and deletion of items
|
||||||
if current_widgets.len() != new_widgets.len() {
|
if current_widgets.len() != new_widgets.len() {
|
||||||
@@ -421,7 +462,12 @@ impl Diffable for LayoutGroup {
|
|||||||
current_widgets.clone_from(&new_widgets);
|
current_widgets.clone_from(&new_widgets);
|
||||||
|
|
||||||
// Push back a LayoutGroup update to the diff
|
// Push back a LayoutGroup update to the diff
|
||||||
let new_value = (if is_column { Self::Column { widgets: new_widgets } } else { Self::Row { widgets: new_widgets } }).into_diff_update();
|
let new_value = (if is_column {
|
||||||
|
Self::Column(WidgetColumn { widgets: new_widgets })
|
||||||
|
} else {
|
||||||
|
Self::Row(WidgetRow { widgets: new_widgets })
|
||||||
|
})
|
||||||
|
.into_diff_update();
|
||||||
let widget_path = widget_path.to_vec();
|
let widget_path = widget_path.to_vec();
|
||||||
widget_diffs.push(WidgetDiff { widget_path, new_value });
|
widget_diffs.push(WidgetDiff { widget_path, new_value });
|
||||||
return;
|
return;
|
||||||
@@ -434,22 +480,22 @@ impl Diffable for LayoutGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
Self::Section {
|
Self::Section(WidgetSection {
|
||||||
name: current_name,
|
name: current_name,
|
||||||
description: current_description,
|
description: current_description,
|
||||||
visible: current_visible,
|
visible: current_visible,
|
||||||
pinned: current_pinned,
|
pinned: current_pinned,
|
||||||
id: current_id,
|
id: current_id,
|
||||||
layout: current_layout,
|
layout: current_layout,
|
||||||
},
|
}),
|
||||||
Self::Section {
|
Self::Section(WidgetSection {
|
||||||
name: new_name,
|
name: new_name,
|
||||||
description: new_description,
|
description: new_description,
|
||||||
visible: new_visible,
|
visible: new_visible,
|
||||||
pinned: new_pinned,
|
pinned: new_pinned,
|
||||||
id: new_id,
|
id: new_id,
|
||||||
layout: new_layout,
|
layout: new_layout,
|
||||||
},
|
}),
|
||||||
) => {
|
) => {
|
||||||
// Resend the entire panel if the lengths, names, visibility, or node IDs are different
|
// Resend the entire panel if the lengths, names, visibility, or node IDs are different
|
||||||
// TODO: Diff insersion and deletion of items
|
// TODO: Diff insersion and deletion of items
|
||||||
@@ -469,14 +515,14 @@ impl Diffable for LayoutGroup {
|
|||||||
current_layout.clone_from(&new_layout);
|
current_layout.clone_from(&new_layout);
|
||||||
|
|
||||||
// Push an update layout group to the diff
|
// Push an update layout group to the diff
|
||||||
let new_value = Self::Section {
|
let new_value = Self::Section(WidgetSection {
|
||||||
name: new_name,
|
name: new_name,
|
||||||
description: new_description,
|
description: new_description,
|
||||||
visible: new_visible,
|
visible: new_visible,
|
||||||
pinned: new_pinned,
|
pinned: new_pinned,
|
||||||
id: new_id,
|
id: new_id,
|
||||||
layout: new_layout,
|
layout: new_layout,
|
||||||
}
|
})
|
||||||
.into_diff_update();
|
.into_diff_update();
|
||||||
let widget_path = widget_path.to_vec();
|
let widget_path = widget_path.to_vec();
|
||||||
widget_diffs.push(WidgetDiff { widget_path, new_value });
|
widget_diffs.push(WidgetDiff { widget_path, new_value });
|
||||||
@@ -501,14 +547,14 @@ impl Diffable for LayoutGroup {
|
|||||||
|
|
||||||
fn collect_checkbox_ids(&self, layout_target: LayoutTarget, widget_path: &mut Vec<usize>, checkbox_map: &mut HashMap<CheckboxId, CheckboxId>) {
|
fn collect_checkbox_ids(&self, layout_target: LayoutTarget, widget_path: &mut Vec<usize>, checkbox_map: &mut HashMap<CheckboxId, CheckboxId>) {
|
||||||
match self {
|
match self {
|
||||||
Self::Column { widgets } | Self::Row { widgets } => {
|
Self::Column(WidgetColumn { widgets }) | Self::Row(WidgetRow { widgets }) => {
|
||||||
for (index, widget) in widgets.iter().enumerate() {
|
for (index, widget) in widgets.iter().enumerate() {
|
||||||
widget_path.push(index);
|
widget_path.push(index);
|
||||||
widget.collect_checkbox_ids(layout_target, widget_path, checkbox_map);
|
widget.collect_checkbox_ids(layout_target, widget_path, checkbox_map);
|
||||||
widget_path.pop();
|
widget_path.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Table { rows, .. } => {
|
Self::Table(WidgetTable { rows, .. }) => {
|
||||||
for (row_idx, row) in rows.iter().enumerate() {
|
for (row_idx, row) in rows.iter().enumerate() {
|
||||||
for (col_idx, widget) in row.iter().enumerate() {
|
for (col_idx, widget) in row.iter().enumerate() {
|
||||||
widget_path.push(row_idx);
|
widget_path.push(row_idx);
|
||||||
@@ -519,7 +565,7 @@ impl Diffable for LayoutGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Section { layout, .. } => {
|
Self::Section(WidgetSection { layout, .. }) => {
|
||||||
layout.collect_checkbox_ids(layout_target, widget_path, checkbox_map);
|
layout.collect_checkbox_ids(layout_target, widget_path, checkbox_map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -527,14 +573,14 @@ impl Diffable for LayoutGroup {
|
|||||||
|
|
||||||
fn replace_widget_ids(&mut self, layout_target: LayoutTarget, widget_path: &mut Vec<usize>, checkbox_map: &HashMap<CheckboxId, CheckboxId>) {
|
fn replace_widget_ids(&mut self, layout_target: LayoutTarget, widget_path: &mut Vec<usize>, checkbox_map: &HashMap<CheckboxId, CheckboxId>) {
|
||||||
match self {
|
match self {
|
||||||
Self::Column { widgets } | Self::Row { widgets } => {
|
Self::Column(WidgetColumn { widgets }) | Self::Row(WidgetRow { widgets }) => {
|
||||||
for (index, widget) in widgets.iter_mut().enumerate() {
|
for (index, widget) in widgets.iter_mut().enumerate() {
|
||||||
widget_path.push(index);
|
widget_path.push(index);
|
||||||
widget.replace_widget_ids(layout_target, widget_path, checkbox_map);
|
widget.replace_widget_ids(layout_target, widget_path, checkbox_map);
|
||||||
widget_path.pop();
|
widget_path.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Table { rows, .. } => {
|
Self::Table(WidgetTable { rows, .. }) => {
|
||||||
for (row_idx, row) in rows.iter_mut().enumerate() {
|
for (row_idx, row) in rows.iter_mut().enumerate() {
|
||||||
for (col_idx, widget) in row.iter_mut().enumerate() {
|
for (col_idx, widget) in row.iter_mut().enumerate() {
|
||||||
widget_path.push(row_idx);
|
widget_path.push(row_idx);
|
||||||
@@ -545,14 +591,15 @@ impl Diffable for LayoutGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Section { layout, .. } => {
|
Self::Section(WidgetSection { layout, .. }) => {
|
||||||
layout.replace_widget_ids(layout_target, widget_path, checkbox_map);
|
layout.replace_widget_ids(layout_target, widget_path, checkbox_map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct WidgetInstance {
|
pub struct WidgetInstance {
|
||||||
#[serde(rename = "widgetId")]
|
#[serde(rename = "widgetId")]
|
||||||
pub widget_id: WidgetId,
|
pub widget_id: WidgetId,
|
||||||
@@ -674,9 +721,8 @@ impl Diffable for WidgetInstance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, specta::Type)]
|
#[derive(Clone)]
|
||||||
pub struct WidgetCallback<T> {
|
pub struct WidgetCallback<T> {
|
||||||
#[specta(skip)]
|
|
||||||
pub callback: Arc<dyn Fn(&T) -> Message + 'static + Send + Sync>,
|
pub callback: Arc<dyn Fn(&T) -> Message + 'static + Send + Sync>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -692,7 +738,8 @@ impl<T> Default for WidgetCallback<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum Widget {
|
pub enum Widget {
|
||||||
BreadcrumbTrailButtons(BreadcrumbTrailButtons),
|
BreadcrumbTrailButtons(BreadcrumbTrailButtons),
|
||||||
CheckboxInput(CheckboxInput),
|
CheckboxInput(CheckboxInput),
|
||||||
@@ -719,7 +766,8 @@ pub enum Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A single change to part of the UI, containing the location of the change and the new value.
|
/// A single change to part of the UI, containing the location of the change and the new value.
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct WidgetDiff {
|
pub struct WidgetDiff {
|
||||||
/// A path to the change
|
/// A path to the change
|
||||||
/// e.g. [0, 1, 2] in the properties panel is the first section, second row and third widget.
|
/// e.g. [0, 1, 2] in the properties panel is the first section, second row and third widget.
|
||||||
@@ -732,7 +780,8 @@ pub struct WidgetDiff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The new value of the UI, sent as part of a diff.
|
/// The new value of the UI, sent as part of a diff.
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum DiffUpdate {
|
pub enum DiffUpdate {
|
||||||
#[serde(rename = "layout")]
|
#[serde(rename = "layout")]
|
||||||
Layout(Layout),
|
Layout(Layout),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::messages::frontend::IconName;
|
||||||
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
||||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||||
use crate::messages::portfolio::document::node_graph::utility_types::FrontendGraphDataType;
|
use crate::messages::portfolio::document::node_graph::utility_types::FrontendGraphDataType;
|
||||||
@@ -6,12 +7,14 @@ use derivative::*;
|
|||||||
use graphene_std::vector::style::FillChoice;
|
use graphene_std::vector::style::FillChoice;
|
||||||
use graphite_proc_macros::WidgetBuilder;
|
use graphite_proc_macros::WidgetBuilder;
|
||||||
|
|
||||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub struct IconButton {
|
pub struct IconButton {
|
||||||
// Content
|
// Content
|
||||||
#[widget_builder(constructor)]
|
#[widget_builder(constructor)]
|
||||||
pub icon: String,
|
#[widget_builder(string)]
|
||||||
|
pub icon: IconName,
|
||||||
#[serde(rename = "hoverIcon")]
|
#[serde(rename = "hoverIcon")]
|
||||||
pub hover_icon: Option<String>,
|
pub hover_icon: Option<String>,
|
||||||
#[widget_builder(constructor)]
|
#[widget_builder(constructor)]
|
||||||
@@ -38,12 +41,14 @@ pub struct IconButton {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq, Default)]
|
#[derivative(Debug, PartialEq, Default)]
|
||||||
pub struct PopoverButton {
|
pub struct PopoverButton {
|
||||||
// Content
|
// Content
|
||||||
pub style: Option<String>,
|
pub style: Option<String>,
|
||||||
pub icon: Option<String>,
|
#[widget_builder(string)]
|
||||||
|
pub icon: Option<IconName>,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
|
|
||||||
// Children
|
// Children
|
||||||
@@ -63,7 +68,8 @@ pub struct PopoverButton {
|
|||||||
pub tooltip_shortcut: Option<ActionShortcut>,
|
pub tooltip_shortcut: Option<ActionShortcut>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Default, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum MenuDirection {
|
pub enum MenuDirection {
|
||||||
Top,
|
Top,
|
||||||
#[default]
|
#[default]
|
||||||
@@ -77,7 +83,8 @@ pub enum MenuDirection {
|
|||||||
Center,
|
Center,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub struct ParameterExposeButton {
|
pub struct ParameterExposeButton {
|
||||||
// Content
|
// Content
|
||||||
@@ -102,13 +109,15 @@ pub struct ParameterExposeButton {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub struct TextButton {
|
pub struct TextButton {
|
||||||
// Content
|
// Content
|
||||||
#[widget_builder(constructor)]
|
#[widget_builder(constructor)]
|
||||||
pub label: String,
|
pub label: String,
|
||||||
pub icon: Option<String>,
|
#[widget_builder(string)]
|
||||||
|
pub icon: Option<IconName>,
|
||||||
#[serde(rename = "hoverIcon")]
|
#[serde(rename = "hoverIcon")]
|
||||||
pub hover_icon: Option<String>,
|
pub hover_icon: Option<String>,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
@@ -146,7 +155,8 @@ pub struct TextButton {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub struct ImageButton {
|
pub struct ImageButton {
|
||||||
// Content
|
// Content
|
||||||
@@ -172,7 +182,8 @@ pub struct ImageButton {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq, Default)]
|
#[derivative(Debug, PartialEq, Default)]
|
||||||
pub struct ColorInput {
|
pub struct ColorInput {
|
||||||
// Content
|
// Content
|
||||||
@@ -207,7 +218,8 @@ pub struct ColorInput {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub struct BreadcrumbTrailButtons {
|
pub struct BreadcrumbTrailButtons {
|
||||||
// Content
|
// Content
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::messages::frontend::IconName;
|
||||||
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
||||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier;
|
use crate::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier;
|
||||||
@@ -7,14 +8,15 @@ use graphene_std::raster::curve::Curve;
|
|||||||
use graphene_std::transform::ReferencePoint;
|
use graphene_std::transform::ReferencePoint;
|
||||||
use graphite_proc_macros::WidgetBuilder;
|
use graphite_proc_macros::WidgetBuilder;
|
||||||
|
|
||||||
#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||||
#[derivative(Debug, Default, PartialEq)]
|
#[derivative(Debug, Default, PartialEq)]
|
||||||
pub struct CheckboxInput {
|
pub struct CheckboxInput {
|
||||||
// Content
|
// Content
|
||||||
#[widget_builder(constructor)]
|
#[widget_builder(constructor)]
|
||||||
pub checked: bool,
|
pub checked: bool,
|
||||||
#[derivative(Default(value = "\"Checkmark\".to_string()"))]
|
#[widget_builder(string)]
|
||||||
pub icon: String,
|
pub icon: Option<IconName>,
|
||||||
#[serde(rename = "forLabel")]
|
#[serde(rename = "forLabel")]
|
||||||
pub for_label: CheckboxId,
|
pub for_label: CheckboxId,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
@@ -36,6 +38,7 @@ pub struct CheckboxInput {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct CheckboxId(pub u64);
|
pub struct CheckboxId(pub u64);
|
||||||
|
|
||||||
@@ -49,14 +52,9 @@ impl Default for CheckboxId {
|
|||||||
Self::new()
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq, Default)]
|
#[derivative(Debug, PartialEq, Default)]
|
||||||
pub struct DropdownInput {
|
pub struct DropdownInput {
|
||||||
// Content
|
// Content
|
||||||
@@ -102,7 +100,8 @@ pub struct DropdownInput {
|
|||||||
|
|
||||||
pub type MenuListEntrySections = Vec<Vec<MenuListEntry>>;
|
pub type MenuListEntrySections = Vec<Vec<MenuListEntry>>;
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
#[widget_builder(not_widget_instance)]
|
#[widget_builder(not_widget_instance)]
|
||||||
pub struct MenuListEntry {
|
pub struct MenuListEntry {
|
||||||
@@ -110,7 +109,8 @@ pub struct MenuListEntry {
|
|||||||
#[widget_builder(constructor)]
|
#[widget_builder(constructor)]
|
||||||
pub value: String,
|
pub value: String,
|
||||||
pub label: String,
|
pub label: String,
|
||||||
pub icon: String,
|
#[widget_builder(string)]
|
||||||
|
pub icon: Option<IconName>,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
|
|
||||||
// Children
|
// Children
|
||||||
@@ -120,7 +120,7 @@ pub struct MenuListEntry {
|
|||||||
pub children_hash: u64,
|
pub children_hash: u64,
|
||||||
|
|
||||||
// Styling
|
// Styling
|
||||||
pub font: String,
|
pub font: Option<String>,
|
||||||
|
|
||||||
// Tooltips
|
// Tooltips
|
||||||
#[serde(rename = "tooltipLabel")]
|
#[serde(rename = "tooltipLabel")]
|
||||||
@@ -148,7 +148,8 @@ impl std::hash::Hash for MenuListEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq, Default)]
|
#[derivative(Debug, PartialEq, Default)]
|
||||||
pub struct NumberInput {
|
pub struct NumberInput {
|
||||||
// Content
|
// Content
|
||||||
@@ -246,22 +247,30 @@ impl NumberInput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Debug, Default, PartialEq, Eq, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Debug, Default, PartialEq, Eq)]
|
||||||
pub enum NumberInputIncrementBehavior {
|
pub enum NumberInputIncrementBehavior {
|
||||||
|
/// The value is added by `step`.
|
||||||
#[default]
|
#[default]
|
||||||
Add,
|
Add,
|
||||||
|
/// The value is multiplied by `step`.
|
||||||
Multiply,
|
Multiply,
|
||||||
|
/// The functions `incrementCallbackIncrease` and `incrementCallbackDecrease` call custom behavior.
|
||||||
Callback,
|
Callback,
|
||||||
|
/// The increment arrows are not shown.
|
||||||
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Debug, Default, PartialEq, Eq, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Debug, Default, PartialEq, Eq)]
|
||||||
pub enum NumberInputMode {
|
pub enum NumberInputMode {
|
||||||
#[default]
|
#[default]
|
||||||
Increment,
|
Increment,
|
||||||
Range,
|
Range,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq, Default)]
|
#[derivative(Debug, PartialEq, Default)]
|
||||||
pub struct NodeCatalog {
|
pub struct NodeCatalog {
|
||||||
// Content
|
// Content
|
||||||
@@ -280,7 +289,8 @@ pub struct NodeCatalog {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub struct RadioInput {
|
pub struct RadioInput {
|
||||||
// Content
|
// Content
|
||||||
@@ -303,7 +313,8 @@ pub struct RadioInput {
|
|||||||
// Callbacks exists on the `RadioEntryData` children, not this parent `RadioInput`
|
// Callbacks exists on the `RadioEntryData` children, not this parent `RadioInput`
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
#[widget_builder(not_widget_instance)]
|
#[widget_builder(not_widget_instance)]
|
||||||
pub struct RadioEntryData {
|
pub struct RadioEntryData {
|
||||||
@@ -311,7 +322,8 @@ pub struct RadioEntryData {
|
|||||||
#[widget_builder(constructor)]
|
#[widget_builder(constructor)]
|
||||||
pub value: String,
|
pub value: String,
|
||||||
pub label: String,
|
pub label: String,
|
||||||
pub icon: String,
|
#[widget_builder(string)]
|
||||||
|
pub icon: Option<IconName>,
|
||||||
|
|
||||||
// Tooltips
|
// Tooltips
|
||||||
#[serde(rename = "tooltipLabel")]
|
#[serde(rename = "tooltipLabel")]
|
||||||
@@ -330,7 +342,8 @@ pub struct RadioEntryData {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq, Default)]
|
#[derivative(Debug, PartialEq, Default)]
|
||||||
pub struct WorkingColorsInput {
|
pub struct WorkingColorsInput {
|
||||||
// Content
|
// Content
|
||||||
@@ -340,7 +353,8 @@ pub struct WorkingColorsInput {
|
|||||||
pub secondary: Color,
|
pub secondary: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq, Default)]
|
#[derivative(Debug, PartialEq, Default)]
|
||||||
pub struct TextAreaInput {
|
pub struct TextAreaInput {
|
||||||
// Content
|
// Content
|
||||||
@@ -366,7 +380,8 @@ pub struct TextAreaInput {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq, Default)]
|
#[derivative(Debug, PartialEq, Default)]
|
||||||
pub struct TextInput {
|
pub struct TextInput {
|
||||||
// Content
|
// Content
|
||||||
@@ -403,7 +418,8 @@ pub struct TextInput {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq, Default)]
|
#[derivative(Debug, PartialEq, Default)]
|
||||||
pub struct CurveInput {
|
pub struct CurveInput {
|
||||||
// Content
|
// Content
|
||||||
@@ -427,7 +443,8 @@ pub struct CurveInput {
|
|||||||
pub on_commit: WidgetCallback<()>,
|
pub on_commit: WidgetCallback<()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub struct ReferencePointInput {
|
pub struct ReferencePointInput {
|
||||||
// Content
|
// Content
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
use super::input_widgets::CheckboxId;
|
use super::input_widgets::CheckboxId;
|
||||||
use crate::messages::input_mapper::utility_types::misc::ActionShortcut;
|
use crate::messages::{frontend::IconName, input_mapper::utility_types::misc::ActionShortcut};
|
||||||
use derivative::*;
|
use derivative::*;
|
||||||
use graphite_proc_macros::WidgetBuilder;
|
use graphite_proc_macros::WidgetBuilder;
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Default, PartialEq, Eq, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Default, PartialEq, Eq, WidgetBuilder)]
|
||||||
pub struct IconLabel {
|
pub struct IconLabel {
|
||||||
// Content
|
// Content
|
||||||
#[widget_builder(constructor)]
|
#[widget_builder(constructor)]
|
||||||
pub icon: String,
|
#[widget_builder(string)]
|
||||||
|
pub icon: IconName,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
|
|
||||||
// Tooltips
|
// Tooltips
|
||||||
@@ -19,7 +21,8 @@ pub struct IconLabel {
|
|||||||
pub tooltip_shortcut: Option<ActionShortcut>,
|
pub tooltip_shortcut: Option<ActionShortcut>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, WidgetBuilder)]
|
||||||
pub struct Separator {
|
pub struct Separator {
|
||||||
// Content
|
// Content
|
||||||
pub direction: SeparatorDirection,
|
pub direction: SeparatorDirection,
|
||||||
@@ -27,14 +30,16 @@ pub struct Separator {
|
|||||||
pub style: SeparatorStyle,
|
pub style: SeparatorStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum SeparatorDirection {
|
pub enum SeparatorDirection {
|
||||||
#[default]
|
#[default]
|
||||||
Horizontal,
|
Horizontal,
|
||||||
Vertical,
|
Vertical,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum SeparatorStyle {
|
pub enum SeparatorStyle {
|
||||||
Related,
|
Related,
|
||||||
#[default]
|
#[default]
|
||||||
@@ -42,7 +47,8 @@ pub enum SeparatorStyle {
|
|||||||
Section,
|
Section,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Eq, Default, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Eq, Default, WidgetBuilder)]
|
||||||
#[derivative(PartialEq)]
|
#[derivative(PartialEq)]
|
||||||
pub struct TextLabel {
|
pub struct TextLabel {
|
||||||
// Content
|
// Content
|
||||||
@@ -78,7 +84,8 @@ pub struct TextLabel {
|
|||||||
pub tooltip_shortcut: Option<ActionShortcut>,
|
pub tooltip_shortcut: Option<ActionShortcut>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub struct ImageLabel {
|
pub struct ImageLabel {
|
||||||
// Content
|
// Content
|
||||||
@@ -96,7 +103,8 @@ pub struct ImageLabel {
|
|||||||
pub tooltip_shortcut: Option<ActionShortcut>,
|
pub tooltip_shortcut: Option<ActionShortcut>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||||
#[derivative(Debug, PartialEq)]
|
#[derivative(Debug, PartialEq)]
|
||||||
pub struct ShortcutLabel {
|
pub struct ShortcutLabel {
|
||||||
// Content
|
// 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::layout::utility_types::widget_prelude::*;
|
||||||
use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate, AlignAxis, FlipAxis, GroupFolderType};
|
use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate, AlignAxis, FlipAxis, GroupFolderType};
|
||||||
use crate::messages::prelude::*;
|
use crate::messages::prelude::*;
|
||||||
use graphene_std::path_bool::BooleanOperation;
|
use graphene_std::vector::misc::BooleanOperation;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, ExtractField)]
|
#[derive(Debug, Clone, Default, ExtractField)]
|
||||||
pub struct MenuBarMessageHandler {
|
pub struct MenuBarMessageHandler {
|
||||||
@@ -76,7 +76,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||||||
TextButton::new("Graphite")
|
TextButton::new("Graphite")
|
||||||
.label("")
|
.label("")
|
||||||
.flush(true)
|
.flush(true)
|
||||||
.icon(Some("GraphiteLogo".into()))
|
.icon("GraphiteLogo")
|
||||||
.on_commit(|_| FrontendMessage::TriggerVisitLink { url: "https://graphite.art".into() }.into())
|
.on_commit(|_| FrontendMessage::TriggerVisitLink { url: "https://graphite.art".into() }.into())
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
@@ -750,6 +750,6 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
];
|
];
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets: menu_bar_buttons }])
|
Layout(vec![LayoutGroup::row(menu_bar_buttons)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,14 +45,6 @@ pub enum Message {
|
|||||||
NoOp,
|
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 {
|
impl Message {
|
||||||
pub fn message_tree() -> DebugMessageTree {
|
pub fn message_tree() -> DebugMessageTree {
|
||||||
Self::build_message_tree()
|
Self::build_message_tree()
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ impl DataPanelMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !widgets.is_empty() {
|
if !widgets.is_empty() {
|
||||||
layout.0.insert(0, LayoutGroup::Row { widgets });
|
layout.0.insert(0, LayoutGroup::row(widgets));
|
||||||
}
|
}
|
||||||
|
|
||||||
responses.add(LayoutMessage::SendLayout {
|
responses.add(LayoutMessage::SendLayout {
|
||||||
@@ -185,7 +185,7 @@ fn column_headings(value: &[&str]) -> Vec<WidgetInstance> {
|
|||||||
|
|
||||||
fn label(x: impl Into<String>) -> Vec<LayoutGroup> {
|
fn label(x: impl Into<String>) -> Vec<LayoutGroup> {
|
||||||
let error = vec![TextLabel::new(x).widget_instance()];
|
let error = vec![TextLabel::new(x).widget_instance()];
|
||||||
vec![LayoutGroup::Row { widgets: error }]
|
vec![LayoutGroup::row(error)]
|
||||||
}
|
}
|
||||||
|
|
||||||
trait TableRowLayout {
|
trait TableRowLayout {
|
||||||
@@ -234,7 +234,7 @@ impl<T: TableRowLayout> TableRowLayout for Vec<T> {
|
|||||||
|
|
||||||
rows.insert(0, column_headings(&["", "element"]));
|
rows.insert(0, column_headings(&["", "element"]));
|
||||||
|
|
||||||
vec![LayoutGroup::Table { rows, unstyled: false }]
|
vec![LayoutGroup::table(rows, false)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ impl<T: TableRowLayout> TableRowLayout for Table<T> {
|
|||||||
|
|
||||||
rows.insert(0, column_headings(&["", "element", "transform", "alpha_blending", "source_node_id"]));
|
rows.insert(0, column_headings(&["", "element", "transform", "alpha_blending", "source_node_id"]));
|
||||||
|
|
||||||
vec![LayoutGroup::Table { rows, unstyled: false }]
|
vec![LayoutGroup::table(rows, false)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ impl TableRowLayout for Vector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec![LayoutGroup::Row { widgets: table_tabs }, LayoutGroup::Table { rows: table_rows, unstyled: false }]
|
vec![LayoutGroup::row(table_tabs), LayoutGroup::table(table_rows, false)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,7 +504,7 @@ impl TableRowLayout for Raster<CPU> {
|
|||||||
|
|
||||||
if raster.width == 0 || raster.height == 0 {
|
if raster.width == 0 || raster.height == 0 {
|
||||||
let widgets = vec![TextLabel::new("Image has no area").widget_instance()];
|
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(|| {
|
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()];
|
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> {
|
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()];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![self.element_widget(0)];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![self.element_widget(0)];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![TextLabel::new(self.to_string()).widget_instance()];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![TextAreaInput::new(self.to_string()).disabled(true).widget_instance()];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![TextLabel::new(format!("{self:?}")).widget_instance()];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![TextLabel::new(format!("({}, {})", self.x, self.y)).widget_instance()];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![TextLabel::new(format!("({}, {})", self.x, self.y)).widget_instance()];
|
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> {
|
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
let widgets = vec![TextLabel::new(format_transform_matrix(self)).widget_instance()];
|
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> {
|
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 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()];
|
let widgets = vec![TextLabel::new(format_transform_matrix(&matrix)).widget_instance()];
|
||||||
vec![LayoutGroup::Row { widgets }]
|
vec![LayoutGroup::row(widgets)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use super::node_graph::document_node_definitions;
|
use super::node_graph::document_node_definitions;
|
||||||
use super::node_graph::utility_types::Transform;
|
|
||||||
use super::utility_types::error::EditorError;
|
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::misc::{GroupFolderType, SNAP_FUNCTIONS_FOR_BOUNDING_BOXES, SNAP_FUNCTIONS_FOR_PATHS, SnappingOptions, SnappingState};
|
||||||
use super::utility_types::network_interface::{self, NodeNetworkInterface, TransactionStatus};
|
use super::utility_types::network_interface::{self, NodeNetworkInterface, TransactionStatus};
|
||||||
@@ -30,7 +29,7 @@ use glam::{DAffine2, DVec2, IVec2};
|
|||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork};
|
use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork};
|
||||||
use graphene_std::math::quad::Quad;
|
use graphene_std::math::quad::Quad;
|
||||||
use graphene_std::path_bool::{boolean_intersect, path_bool_lib};
|
use graphene_std::path_bool_nodes::boolean_intersect;
|
||||||
use graphene_std::raster::BlendMode;
|
use graphene_std::raster::BlendMode;
|
||||||
use graphene_std::raster_types::Raster;
|
use graphene_std::raster_types::Raster;
|
||||||
use graphene_std::render_node::wgpu_available;
|
use graphene_std::render_node::wgpu_available;
|
||||||
@@ -38,9 +37,9 @@ use graphene_std::subpath::Subpath;
|
|||||||
use graphene_std::table::Table;
|
use graphene_std::table::Table;
|
||||||
use graphene_std::vector::PointId;
|
use graphene_std::vector::PointId;
|
||||||
use graphene_std::vector::click_target::{ClickTarget, ClickTargetType};
|
use graphene_std::vector::click_target::{ClickTarget, ClickTargetType};
|
||||||
use graphene_std::vector::misc::{dvec2_to_point, point_to_dvec2};
|
use graphene_std::vector::misc::dvec2_to_point;
|
||||||
use graphene_std::vector::style::RenderMode;
|
use graphene_std::vector::style::RenderMode;
|
||||||
use kurbo::{Affine, CubicBez, Line, ParamCurve, PathSeg, QuadBez};
|
use kurbo::{Affine, BezPath, Line, PathSeg};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -590,6 +589,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
|||||||
responses.add(DocumentMessage::RenderScrollbars);
|
responses.add(DocumentMessage::RenderScrollbars);
|
||||||
if opened {
|
if opened {
|
||||||
responses.add(NodeGraphMessage::UnloadWires);
|
responses.add(NodeGraphMessage::UnloadWires);
|
||||||
|
responses.add(NodeGraphMessage::UpdateNodeGraphWidth);
|
||||||
}
|
}
|
||||||
if open {
|
if open {
|
||||||
responses.add(ToolMessage::DeactivateTools);
|
responses.add(ToolMessage::DeactivateTools);
|
||||||
@@ -848,7 +848,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
|||||||
document_id,
|
document_id,
|
||||||
name: format!("{}.{}", self.name.clone(), FILE_EXTENSION),
|
name: format!("{}.{}", self.name.clone(), FILE_EXTENSION),
|
||||||
path: self.path.clone(),
|
path: self.path.clone(),
|
||||||
content: self.serialize_document().into_bytes(),
|
content: self.serialize_document().into_bytes().into(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
DocumentMessage::SavedDocument { path } => {
|
DocumentMessage::SavedDocument { path } => {
|
||||||
@@ -1332,11 +1332,8 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
|||||||
responses.add(NodeGraphMessage::UpdateImportsExports);
|
responses.add(NodeGraphMessage::UpdateImportsExports);
|
||||||
|
|
||||||
responses.add(FrontendMessage::UpdateNodeGraphTransform {
|
responses.add(FrontendMessage::UpdateNodeGraphTransform {
|
||||||
transform: Transform {
|
translation: transform.translation.into(),
|
||||||
scale: transform.matrix2.x_axis.x,
|
scale: transform.matrix2.x_axis.x,
|
||||||
x: transform.translation.x,
|
|
||||||
y: transform.translation.y,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2216,256 +2213,222 @@ impl DocumentMessageHandler {
|
|||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
PopoverButton::new()
|
PopoverButton::new()
|
||||||
.popover_layout(Layout(vec![
|
.popover_layout(Layout(vec![
|
||||||
LayoutGroup::Row {
|
LayoutGroup::row(vec![TextLabel::new("Overlays").bold(true).widget_instance()]),
|
||||||
widgets: vec![TextLabel::new("Overlays").bold(true).widget_instance()],
|
LayoutGroup::row(vec![TextLabel::new("General").widget_instance()]),
|
||||||
},
|
LayoutGroup::row({
|
||||||
LayoutGroup::Row {
|
let checkbox_id = CheckboxId::new();
|
||||||
widgets: vec![TextLabel::new("General").widget_instance()],
|
vec![
|
||||||
},
|
CheckboxInput::new(self.overlays_visibility_settings.artboard_name)
|
||||||
LayoutGroup::Row {
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
widgets: {
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
let checkbox_id = CheckboxId::new();
|
visible: optional_input.checked,
|
||||||
vec![
|
overlays_type: Some(OverlaysType::ArtboardName),
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.artboard_name)
|
}
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
.into()
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
})
|
||||||
visible: optional_input.checked,
|
.for_label(checkbox_id)
|
||||||
overlays_type: Some(OverlaysType::ArtboardName),
|
.widget_instance(),
|
||||||
}
|
TextLabel::new("Artboard Name".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
.into()
|
]
|
||||||
})
|
}),
|
||||||
.for_label(checkbox_id)
|
LayoutGroup::row({
|
||||||
.widget_instance(),
|
let checkbox_id = CheckboxId::new();
|
||||||
TextLabel::new("Artboard Name".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
vec![
|
||||||
]
|
CheckboxInput::new(self.overlays_visibility_settings.transform_measurement)
|
||||||
},
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
},
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
LayoutGroup::Row {
|
visible: optional_input.checked,
|
||||||
widgets: {
|
overlays_type: Some(OverlaysType::TransformMeasurement),
|
||||||
let checkbox_id = CheckboxId::new();
|
}
|
||||||
vec![
|
.into()
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.transform_measurement)
|
})
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
.for_label(checkbox_id)
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
.widget_instance(),
|
||||||
visible: optional_input.checked,
|
TextLabel::new("G/R/S Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
overlays_type: Some(OverlaysType::TransformMeasurement),
|
]
|
||||||
}
|
}),
|
||||||
.into()
|
LayoutGroup::row(vec![TextLabel::new("Select Tool").widget_instance()]),
|
||||||
})
|
LayoutGroup::row({
|
||||||
.for_label(checkbox_id)
|
let checkbox_id = CheckboxId::new();
|
||||||
.widget_instance(),
|
vec![
|
||||||
TextLabel::new("G/R/S Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
CheckboxInput::new(self.overlays_visibility_settings.quick_measurement)
|
||||||
]
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
},
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
},
|
visible: optional_input.checked,
|
||||||
LayoutGroup::Row {
|
overlays_type: Some(OverlaysType::QuickMeasurement),
|
||||||
widgets: vec![TextLabel::new("Select Tool").widget_instance()],
|
}
|
||||||
},
|
.into()
|
||||||
LayoutGroup::Row {
|
})
|
||||||
widgets: {
|
.for_label(checkbox_id)
|
||||||
let checkbox_id = CheckboxId::new();
|
.widget_instance(),
|
||||||
vec![
|
TextLabel::new("Quick Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.quick_measurement)
|
]
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
}),
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
LayoutGroup::row({
|
||||||
visible: optional_input.checked,
|
let checkbox_id = CheckboxId::new();
|
||||||
overlays_type: Some(OverlaysType::QuickMeasurement),
|
vec![
|
||||||
}
|
CheckboxInput::new(self.overlays_visibility_settings.transform_cage)
|
||||||
.into()
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
})
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
.for_label(checkbox_id)
|
visible: optional_input.checked,
|
||||||
.widget_instance(),
|
overlays_type: Some(OverlaysType::TransformCage),
|
||||||
TextLabel::new("Quick Measurement".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
}
|
||||||
]
|
.into()
|
||||||
},
|
})
|
||||||
},
|
.for_label(checkbox_id)
|
||||||
LayoutGroup::Row {
|
.widget_instance(),
|
||||||
widgets: {
|
TextLabel::new("Transform Cage".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
let checkbox_id = CheckboxId::new();
|
]
|
||||||
vec![
|
}),
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.transform_cage)
|
LayoutGroup::row({
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
let checkbox_id = CheckboxId::new();
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
vec![
|
||||||
visible: optional_input.checked,
|
CheckboxInput::new(self.overlays_visibility_settings.compass_rose)
|
||||||
overlays_type: Some(OverlaysType::TransformCage),
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
}
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
.into()
|
visible: optional_input.checked,
|
||||||
})
|
overlays_type: Some(OverlaysType::CompassRose),
|
||||||
.for_label(checkbox_id)
|
}
|
||||||
.widget_instance(),
|
.into()
|
||||||
TextLabel::new("Transform Cage".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
})
|
||||||
]
|
.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();
|
LayoutGroup::row({
|
||||||
vec![
|
let checkbox_id = CheckboxId::new();
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.compass_rose)
|
vec![
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
CheckboxInput::new(self.overlays_visibility_settings.pivot)
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
visible: optional_input.checked,
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
overlays_type: Some(OverlaysType::CompassRose),
|
visible: optional_input.checked,
|
||||||
}
|
overlays_type: Some(OverlaysType::Pivot),
|
||||||
.into()
|
}
|
||||||
})
|
.into()
|
||||||
.for_label(checkbox_id)
|
})
|
||||||
.widget_instance(),
|
.for_label(checkbox_id)
|
||||||
TextLabel::new("Transform Dial".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
.widget_instance(),
|
||||||
]
|
TextLabel::new("Transform Pivot".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
},
|
]
|
||||||
},
|
}),
|
||||||
LayoutGroup::Row {
|
LayoutGroup::row({
|
||||||
widgets: {
|
let checkbox_id = CheckboxId::new();
|
||||||
let checkbox_id = CheckboxId::new();
|
vec![
|
||||||
vec![
|
CheckboxInput::new(self.overlays_visibility_settings.origin)
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.pivot)
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
visible: optional_input.checked,
|
||||||
visible: optional_input.checked,
|
overlays_type: Some(OverlaysType::Origin),
|
||||||
overlays_type: Some(OverlaysType::Pivot),
|
}
|
||||||
}
|
.into()
|
||||||
.into()
|
})
|
||||||
})
|
.for_label(checkbox_id)
|
||||||
.for_label(checkbox_id)
|
.widget_instance(),
|
||||||
.widget_instance(),
|
TextLabel::new("Transform Origin".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
TextLabel::new("Transform Pivot".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
]
|
||||||
]
|
}),
|
||||||
},
|
LayoutGroup::row({
|
||||||
},
|
let checkbox_id = CheckboxId::new();
|
||||||
LayoutGroup::Row {
|
vec![
|
||||||
widgets: {
|
CheckboxInput::new(self.overlays_visibility_settings.hover_outline)
|
||||||
let checkbox_id = CheckboxId::new();
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
vec![
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.pivot)
|
visible: optional_input.checked,
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
overlays_type: Some(OverlaysType::HoverOutline),
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
}
|
||||||
visible: optional_input.checked,
|
.into()
|
||||||
overlays_type: Some(OverlaysType::Origin),
|
})
|
||||||
}
|
.for_label(checkbox_id)
|
||||||
.into()
|
.widget_instance(),
|
||||||
})
|
TextLabel::new("Hover Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
.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.selection_outline)
|
||||||
LayoutGroup::Row {
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
widgets: {
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
let checkbox_id = CheckboxId::new();
|
visible: optional_input.checked,
|
||||||
vec![
|
overlays_type: Some(OverlaysType::SelectionOutline),
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.hover_outline)
|
}
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
.into()
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
})
|
||||||
visible: optional_input.checked,
|
.for_label(checkbox_id)
|
||||||
overlays_type: Some(OverlaysType::HoverOutline),
|
.widget_instance(),
|
||||||
}
|
TextLabel::new("Selection Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
.into()
|
]
|
||||||
})
|
}),
|
||||||
.for_label(checkbox_id)
|
LayoutGroup::row({
|
||||||
.widget_instance(),
|
let checkbox_id = CheckboxId::new();
|
||||||
TextLabel::new("Hover Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
vec![
|
||||||
]
|
CheckboxInput::new(self.overlays_visibility_settings.layer_origin_cross)
|
||||||
},
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
},
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
LayoutGroup::Row {
|
visible: optional_input.checked,
|
||||||
widgets: {
|
overlays_type: Some(OverlaysType::LayerOriginCross),
|
||||||
let checkbox_id = CheckboxId::new();
|
}
|
||||||
vec![
|
.into()
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.selection_outline)
|
})
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
.for_label(checkbox_id)
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
.widget_instance(),
|
||||||
visible: optional_input.checked,
|
TextLabel::new("Layer Origin".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
overlays_type: Some(OverlaysType::SelectionOutline),
|
]
|
||||||
}
|
}),
|
||||||
.into()
|
LayoutGroup::row(vec![TextLabel::new("Pen & Path Tools").widget_instance()]),
|
||||||
})
|
LayoutGroup::row({
|
||||||
.for_label(checkbox_id)
|
let checkbox_id = CheckboxId::new();
|
||||||
.widget_instance(),
|
vec![
|
||||||
TextLabel::new("Selection Outline".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
CheckboxInput::new(self.overlays_visibility_settings.path)
|
||||||
]
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
},
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
},
|
visible: optional_input.checked,
|
||||||
LayoutGroup::Row {
|
overlays_type: Some(OverlaysType::Path),
|
||||||
widgets: {
|
}
|
||||||
let checkbox_id = CheckboxId::new();
|
.into()
|
||||||
vec![
|
})
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.layer_origin_cross)
|
.for_label(checkbox_id)
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
.widget_instance(),
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
TextLabel::new("Path".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
visible: optional_input.checked,
|
]
|
||||||
overlays_type: Some(OverlaysType::LayerOriginCross),
|
}),
|
||||||
}
|
LayoutGroup::row({
|
||||||
.into()
|
let checkbox_id = CheckboxId::new();
|
||||||
})
|
vec![
|
||||||
.for_label(checkbox_id)
|
CheckboxInput::new(self.overlays_visibility_settings.anchors)
|
||||||
.widget_instance(),
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
TextLabel::new("Layer Origin".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
]
|
visible: optional_input.checked,
|
||||||
},
|
overlays_type: Some(OverlaysType::Anchors),
|
||||||
},
|
}
|
||||||
LayoutGroup::Row {
|
.into()
|
||||||
widgets: vec![TextLabel::new("Pen & Path Tools").widget_instance()],
|
})
|
||||||
},
|
.for_label(checkbox_id)
|
||||||
LayoutGroup::Row {
|
.widget_instance(),
|
||||||
widgets: {
|
TextLabel::new("Anchors".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
||||||
let checkbox_id = CheckboxId::new();
|
]
|
||||||
vec![
|
}),
|
||||||
CheckboxInput::new(self.overlays_visibility_settings.path)
|
LayoutGroup::row({
|
||||||
.on_update(|optional_input: &CheckboxInput| {
|
let checkbox_id = CheckboxId::new();
|
||||||
DocumentMessage::SetOverlaysVisibility {
|
vec![
|
||||||
visible: optional_input.checked,
|
CheckboxInput::new(self.overlays_visibility_settings.handles)
|
||||||
overlays_type: Some(OverlaysType::Path),
|
.disabled(!self.overlays_visibility_settings.anchors)
|
||||||
}
|
.on_update(|optional_input: &CheckboxInput| {
|
||||||
.into()
|
DocumentMessage::SetOverlaysVisibility {
|
||||||
})
|
visible: optional_input.checked,
|
||||||
.for_label(checkbox_id)
|
overlays_type: Some(OverlaysType::Handles),
|
||||||
.widget_instance(),
|
}
|
||||||
TextLabel::new("Path".to_string()).for_checkbox(checkbox_id).widget_instance(),
|
.into()
|
||||||
]
|
})
|
||||||
},
|
.for_label(checkbox_id)
|
||||||
},
|
.widget_instance(),
|
||||||
LayoutGroup::Row {
|
TextLabel::new("Handles".to_string())
|
||||||
widgets: {
|
.disabled(!self.overlays_visibility_settings.anchors)
|
||||||
let checkbox_id = CheckboxId::new();
|
.for_checkbox(checkbox_id)
|
||||||
vec![
|
.widget_instance(),
|
||||||
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(),
|
.widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
@@ -2484,16 +2447,12 @@ impl DocumentMessageHandler {
|
|||||||
PopoverButton::new()
|
PopoverButton::new()
|
||||||
.popover_layout(Layout(
|
.popover_layout(Layout(
|
||||||
[
|
[
|
||||||
LayoutGroup::Row {
|
LayoutGroup::row(vec![TextLabel::new("Snapping").bold(true).widget_instance()]),
|
||||||
widgets: 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(SnappingOptions::BoundingBoxes.to_string()).widget_instance()],
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
.into_iter()
|
.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)| {
|
||||||
widgets: {
|
LayoutGroup::row({
|
||||||
let checkbox_id = CheckboxId::new();
|
let checkbox_id = CheckboxId::new();
|
||||||
vec![
|
vec![
|
||||||
CheckboxInput::new(*closure(&mut snapping_state))
|
CheckboxInput::new(*closure(&mut snapping_state))
|
||||||
@@ -2510,13 +2469,11 @@ impl DocumentMessageHandler {
|
|||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_instance(),
|
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_instance(),
|
||||||
]
|
]
|
||||||
},
|
})
|
||||||
}))
|
}))
|
||||||
.chain([LayoutGroup::Row {
|
.chain([LayoutGroup::row(vec![TextLabel::new(SnappingOptions::Paths.to_string()).widget_instance()])])
|
||||||
widgets: vec![TextLabel::new(SnappingOptions::Paths.to_string()).widget_instance()],
|
.chain(SNAP_FUNCTIONS_FOR_PATHS.into_iter().map(|(name, closure, description)| {
|
||||||
}])
|
LayoutGroup::row({
|
||||||
.chain(SNAP_FUNCTIONS_FOR_PATHS.into_iter().map(|(name, closure, description)| LayoutGroup::Row {
|
|
||||||
widgets: {
|
|
||||||
let checkbox_id = CheckboxId::new();
|
let checkbox_id = CheckboxId::new();
|
||||||
vec![
|
vec![
|
||||||
CheckboxInput::new(*closure(&mut snapping_state2))
|
CheckboxInput::new(*closure(&mut snapping_state2))
|
||||||
@@ -2533,7 +2490,7 @@ impl DocumentMessageHandler {
|
|||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_instance(),
|
TextLabel::new(name).tooltip_label(name).tooltip_description(description).for_checkbox(checkbox_id).widget_instance(),
|
||||||
]
|
]
|
||||||
},
|
})
|
||||||
}))
|
}))
|
||||||
.collect(),
|
.collect(),
|
||||||
))
|
))
|
||||||
@@ -2562,11 +2519,12 @@ impl DocumentMessageHandler {
|
|||||||
.icon("RenderModeOutline")
|
.icon("RenderModeOutline")
|
||||||
.tooltip_label("Render Mode: Outline")
|
.tooltip_label("Render Mode: Outline")
|
||||||
.on_update(|_| DocumentMessage::SetRenderMode { render_mode: RenderMode::Outline }.into()),
|
.on_update(|_| DocumentMessage::SetRenderMode { render_mode: RenderMode::Outline }.into()),
|
||||||
// TODO: See issue #320
|
RadioEntryData::new("PixelPreview").icon("RenderModePixels").tooltip_label("Render Mode: Pixel Preview").on_update(|_| {
|
||||||
// RadioEntryData::new("PixelPreview")
|
DocumentMessage::SetRenderMode {
|
||||||
// .icon("RenderModePixels")
|
render_mode: RenderMode::PixelPreview,
|
||||||
// .tooltip_label("Render Mode: Pixel Preview")
|
}
|
||||||
// .on_update(|_| todo!()),
|
.into()
|
||||||
|
}),
|
||||||
RadioEntryData::new("SvgPreview")
|
RadioEntryData::new("SvgPreview")
|
||||||
.icon("RenderModeSvg")
|
.icon("RenderModeSvg")
|
||||||
.tooltip_label("Render Mode: SVG Preview")
|
.tooltip_label("Render Mode: SVG Preview")
|
||||||
@@ -2577,7 +2535,7 @@ impl DocumentMessageHandler {
|
|||||||
if disabled {
|
if disabled {
|
||||||
for entry in &mut entries {
|
for entry in &mut entries {
|
||||||
entry.tooltip_description = "
|
entry.tooltip_description = "
|
||||||
*Normal* and *Outline* render modes are not available in this browser. For compatibility, *SVG Preview* mode is active as a fallback.\n\
|
*Normal*, *Outline*, and *Pixel Preview* render modes are not available in this browser. For compatibility, *SVG Preview* mode is active as a fallback.\n\
|
||||||
\n\
|
\n\
|
||||||
This functionality requires WebGPU support. Check webgpu.org for browser implementation status.
|
This functionality requires WebGPU support. Check webgpu.org for browser implementation status.
|
||||||
"
|
"
|
||||||
@@ -2630,8 +2588,8 @@ impl DocumentMessageHandler {
|
|||||||
widgets.extend([
|
widgets.extend([
|
||||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
TextButton::new("Node Graph")
|
TextButton::new("Node Graph")
|
||||||
.icon(Some((if self.graph_view_overlay_open { "GraphViewOpen" } else { "GraphViewClosed" }).into()))
|
.icon(if self.graph_view_overlay_open { "GraphViewOpen" } else { "GraphViewClosed" })
|
||||||
.hover_icon(Some((if self.graph_view_overlay_open { "GraphViewClosed" } else { "GraphViewOpen" }).into()))
|
.hover_icon(if self.graph_view_overlay_open { "GraphViewClosed" } else { "GraphViewOpen" })
|
||||||
.tooltip_label(if self.graph_view_overlay_open { "Hide Node Graph" } else { "Show Node Graph" })
|
.tooltip_label(if self.graph_view_overlay_open { "Hide Node Graph" } else { "Show Node Graph" })
|
||||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::GraphViewOverlayToggle))
|
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::GraphViewOverlayToggle))
|
||||||
.on_update(move |_| DocumentMessage::GraphViewOverlayToggle.into())
|
.on_update(move |_| DocumentMessage::GraphViewOverlayToggle.into())
|
||||||
@@ -2639,7 +2597,7 @@ impl DocumentMessageHandler {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
responses.add(LayoutMessage::SendLayout {
|
responses.add(LayoutMessage::SendLayout {
|
||||||
layout: Layout(vec![LayoutGroup::Row { widgets }]),
|
layout: Layout(vec![LayoutGroup::row(widgets)]),
|
||||||
layout_target: LayoutTarget::DocumentBar,
|
layout_target: LayoutTarget::DocumentBar,
|
||||||
});
|
});
|
||||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||||
@@ -2777,25 +2735,25 @@ impl DocumentMessageHandler {
|
|||||||
.tooltip_label("Fill")
|
.tooltip_label("Fill")
|
||||||
.widget_instance(),
|
.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![
|
let widgets = vec![
|
||||||
IconButton::new(if selection_all_locked { "PadlockLocked" } else { "PadlockUnlocked" }, 24)
|
IconButton::new(if selection_all_locked { "PadlockLocked" } else { "PadlockUnlocked" }, 24)
|
||||||
.hover_icon(Some((if selection_all_locked { "PadlockUnlocked" } else { "PadlockLocked" }).into()))
|
.hover_icon(if selection_all_locked { "PadlockUnlocked" } else { "PadlockLocked" })
|
||||||
.tooltip_label(if selection_all_locked { "Unlock Selected" } else { "Lock Selected" })
|
.tooltip_label(if selection_all_locked { "Unlock Selected" } else { "Lock Selected" })
|
||||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ToggleSelectedLocked))
|
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ToggleSelectedLocked))
|
||||||
.on_update(|_| NodeGraphMessage::ToggleSelectedLocked.into())
|
.on_update(|_| NodeGraphMessage::ToggleSelectedLocked.into())
|
||||||
.disabled(!has_selection)
|
.disabled(!has_selection)
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
IconButton::new(if selection_all_visible { "EyeVisible" } else { "EyeHidden" }, 24)
|
IconButton::new(if selection_all_visible { "EyeVisible" } else { "EyeHidden" }, 24)
|
||||||
.hover_icon(Some((if selection_all_visible { "EyeHide" } else { "EyeShow" }).into()))
|
.hover_icon(if selection_all_visible { "EyeHide" } else { "EyeShow" })
|
||||||
.tooltip_label(if selection_all_visible { "Hide Selected" } else { "Show Selected" })
|
.tooltip_label(if selection_all_visible { "Hide Selected" } else { "Show Selected" })
|
||||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ToggleSelectedVisibility))
|
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ToggleSelectedVisibility))
|
||||||
.on_update(|_| DocumentMessage::ToggleSelectedVisibility.into())
|
.on_update(|_| DocumentMessage::ToggleSelectedVisibility.into())
|
||||||
.disabled(!has_selection)
|
.disabled(!has_selection)
|
||||||
.widget_instance(),
|
.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 {
|
responses.add(LayoutMessage::SendLayout {
|
||||||
layout: layers_panel_control_bar_left,
|
layout: layers_panel_control_bar_left,
|
||||||
@@ -2821,7 +2779,7 @@ impl DocumentMessageHandler {
|
|||||||
|
|
||||||
let widgets = vec![
|
let widgets = vec![
|
||||||
PopoverButton::new()
|
PopoverButton::new()
|
||||||
.icon(Some("Node".to_string()))
|
.icon("Node")
|
||||||
.menu_direction(Some(MenuDirection::Top))
|
.menu_direction(Some(MenuDirection::Top))
|
||||||
.tooltip_description("Add an operation to the end of this layer's chain of nodes.")
|
.tooltip_description("Add an operation to the end of this layer's chain of nodes.")
|
||||||
.disabled(!has_selection || has_multiple_selection)
|
.disabled(!has_selection || has_multiple_selection)
|
||||||
@@ -2849,7 +2807,7 @@ impl DocumentMessageHandler {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.widget_instance();
|
.widget_instance();
|
||||||
Layout(vec![LayoutGroup::Row { widgets: vec![node_chooser] }])
|
Layout(vec![LayoutGroup::row(vec![node_chooser])])
|
||||||
})
|
})
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
@@ -2875,7 +2833,7 @@ impl DocumentMessageHandler {
|
|||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
];
|
];
|
||||||
responses.add(LayoutMessage::SendLayout {
|
responses.add(LayoutMessage::SendLayout {
|
||||||
layout: Layout(vec![LayoutGroup::Row { widgets }]),
|
layout: Layout(vec![LayoutGroup::row(widgets)]),
|
||||||
layout_target: LayoutTarget::LayersPanelBottomBar,
|
layout_target: LayoutTarget::LayersPanelBottomBar,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -3024,7 +2982,7 @@ fn default_document_network_interface() -> NodeNetworkInterface {
|
|||||||
enum XRayTarget {
|
enum XRayTarget {
|
||||||
Point(DVec2),
|
Point(DVec2),
|
||||||
Quad(Quad),
|
Quad(Quad),
|
||||||
Path(Vec<path_bool_lib::PathSegment>),
|
Path(BezPath),
|
||||||
Polygon(Subpath<PointId>),
|
Polygon(Subpath<PointId>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3042,17 +3000,12 @@ pub struct ClickXRayIter<'a> {
|
|||||||
parent_targets: Vec<(LayerNodeIdentifier, XRayTarget)>,
|
parent_targets: Vec<(LayerNodeIdentifier, XRayTarget)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quad_to_path_lib_segments(quad: Quad) -> Vec<path_bool_lib::PathSegment> {
|
fn quad_to_kurbo(quad: Quad) -> BezPath {
|
||||||
quad.all_edges().into_iter().map(|[start, end]| path_bool_lib::PathSegment::Line(start, end)).collect()
|
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 click_targets_to_path_lib_segments<'a>(click_targets: impl Iterator<Item = &'a ClickTarget>, transform: DAffine2) -> Vec<path_bool_lib::PathSegment> {
|
fn click_targets_to_kurbo<'a>(click_targets: impl Iterator<Item = &'a ClickTarget>, transform: DAffine2) -> BezPath {
|
||||||
let segment = |bezier: PathSeg| match bezier {
|
let segments = click_targets
|
||||||
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| {
|
.filter_map(|target| {
|
||||||
if let ClickTargetType::Subpath(subpath) = target.target_type() {
|
if let ClickTargetType::Subpath(subpath) = target.target_type() {
|
||||||
Some(subpath.iter())
|
Some(subpath.iter())
|
||||||
@@ -3061,8 +3014,8 @@ fn click_targets_to_path_lib_segments<'a>(click_targets: impl Iterator<Item = &'
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
.map(|bezier| segment(Affine::new(transform.to_cols_array()) * bezier))
|
.map(|bezier| Affine::new(transform.to_cols_array()) * bezier);
|
||||||
.collect()
|
BezPath::from_path_segments(segments)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ClickXRayIter<'a> {
|
impl<'a> ClickXRayIter<'a> {
|
||||||
@@ -3083,22 +3036,8 @@ impl<'a> ClickXRayIter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handles the checking of the layer where the target is a rect or path
|
/// Handles the checking of the layer where the target is a rect or path
|
||||||
fn check_layer_area_target(
|
fn check_layer_area_target(&mut self, click_targets: Option<&[Arc<ClickTarget>]>, clip: bool, layer: LayerNodeIdentifier, path: BezPath, transform: DAffine2) -> XRayResult {
|
||||||
&mut self,
|
let get_clip = || path.segments();
|
||||||
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 intersects = click_targets.is_some_and(|targets| targets.iter().any(|target| target.intersect_path(get_clip, transform)));
|
||||||
let clicked = intersects;
|
let clicked = intersects;
|
||||||
@@ -3107,8 +3046,9 @@ impl<'a> ClickXRayIter<'a> {
|
|||||||
// In the case of a clip path where the area partially intersects, it is necessary to do a boolean operation.
|
// 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).
|
// We do this on this using the target area to reduce computation (as the target area is usually very simple).
|
||||||
if clip && intersects {
|
if clip && intersects {
|
||||||
let clip_path = click_targets_to_path_lib_segments(click_targets.iter().flat_map(|x| x.iter()).map(|x| x.as_ref()), transform);
|
let clip_path = click_targets_to_kurbo(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<_>>();
|
let intersection = boolean_intersect(&path, &clip_path);
|
||||||
|
let subtracted = BezPath::from_path_segments(intersection.iter().flat_map(|p| p.segments()));
|
||||||
if subtracted.is_empty() {
|
if subtracted.is_empty() {
|
||||||
use_children = false;
|
use_children = false;
|
||||||
} else {
|
} else {
|
||||||
@@ -3141,13 +3081,10 @@ impl<'a> ClickXRayIter<'a> {
|
|||||||
use_children: !clip || intersects,
|
use_children: !clip || intersects,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XRayTarget::Quad(quad) => self.check_layer_area_target(click_targets, clip, layer, quad_to_path_lib_segments(*quad), transform),
|
XRayTarget::Quad(quad) => self.check_layer_area_target(click_targets, clip, layer, quad_to_kurbo(*quad), transform),
|
||||||
XRayTarget::Path(path) => self.check_layer_area_target(click_targets, clip, layer, path.clone(), transform),
|
XRayTarget::Path(path) => self.check_layer_area_target(click_targets, clip, layer, path.clone(), transform),
|
||||||
XRayTarget::Polygon(polygon) => {
|
XRayTarget::Polygon(polygon) => {
|
||||||
let polygon = polygon
|
let polygon = BezPath::from_path_segments(polygon.iter_closed());
|
||||||
.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)
|
self.check_layer_area_target(click_targets, clip, layer, polygon, transform)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ pub enum GraphOperationMessage {
|
|||||||
},
|
},
|
||||||
NewBooleanOperationLayer {
|
NewBooleanOperationLayer {
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
operation: graphene_std::path_bool::BooleanOperation,
|
operation: graphene_std::vector::misc::BooleanOperation,
|
||||||
parent: LayerNodeIdentifier,
|
parent: LayerNodeIdentifier,
|
||||||
insert_index: usize,
|
insert_index: usize,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ impl<'a> ModifyInputsContext<'a> {
|
|||||||
LayerNodeIdentifier::new(new_id, self.network_interface)
|
LayerNodeIdentifier::new(new_id, self.network_interface)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_boolean_data(&mut self, operation: graphene_std::path_bool::BooleanOperation, layer: LayerNodeIdentifier) {
|
pub fn insert_boolean_data(&mut self, operation: graphene_std::vector::misc::BooleanOperation, layer: LayerNodeIdentifier) {
|
||||||
let boolean = resolve_network_node_type("Boolean Operation").expect("Boolean node does not exist").node_template_input_override([
|
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::Graphic(Default::default()), true)),
|
||||||
Some(NodeInput::value(TaggedValue::BooleanOperation(operation), false)),
|
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::F64(typesetting.character_spacing), false)),
|
||||||
Some(NodeInput::value(TaggedValue::Bool(typesetting.max_width.is_some()), 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.max_width.unwrap_or(100.)), false)),
|
||||||
Some(NodeInput::value(TaggedValue::Bool(typesetting.max_width.is_some()), false)),
|
Some(NodeInput::value(TaggedValue::Bool(typesetting.max_height.is_some()), false)),
|
||||||
Some(NodeInput::value(TaggedValue::F64(typesetting.max_width.unwrap_or(100.)), false)),
|
Some(NodeInput::value(TaggedValue::F64(typesetting.max_height.unwrap_or(100.)), false)),
|
||||||
Some(NodeInput::value(TaggedValue::F64(typesetting.tilt), false)),
|
Some(NodeInput::value(TaggedValue::F64(typesetting.tilt), false)),
|
||||||
Some(NodeInput::value(TaggedValue::TextAlign(typesetting.align), false)),
|
Some(NodeInput::value(TaggedValue::TextAlign(typesetting.align), false)),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ impl NodePropertiesContext<'_> {
|
|||||||
/// The key used to access definitions for a network node or proto node.
|
/// The key used to access definitions for a network node or proto node.
|
||||||
/// For proto nodes, this is their [`ProtoNodeIdentifier`].
|
/// 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.
|
/// For network nodes, it doesn't necessarily have to be the same as the network's display name, but it often is.
|
||||||
#[derive(Debug, Clone, Hash, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Hash, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
#[serde(tag = "type", content = "data")]
|
#[serde(tag = "type", content = "data")]
|
||||||
pub enum DefinitionIdentifier {
|
pub enum DefinitionIdentifier {
|
||||||
ProtoNode(ProtoNodeIdentifier),
|
ProtoNode(ProtoNodeIdentifier),
|
||||||
@@ -1782,7 +1783,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
|||||||
nodes: vec![
|
nodes: vec![
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
inputs: vec![NodeInput::import(concrete!(Table<Vector>), 0), NodeInput::import(concrete!(vector::style::Fill), 1)],
|
inputs: vec![NodeInput::import(concrete!(Table<Vector>), 0), NodeInput::import(concrete!(vector::style::Fill), 1)],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(path_bool::boolean_operation::IDENTIFIER),
|
implementation: DocumentNodeImplementation::ProtoNode(path_bool_nodes::boolean_operation::IDENTIFIER),
|
||||||
call_argument: generic!(T),
|
call_argument: generic!(T),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@@ -1801,7 +1802,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
|||||||
}),
|
}),
|
||||||
inputs: vec![
|
inputs: vec![
|
||||||
NodeInput::value(TaggedValue::Graphic(Default::default()), true),
|
NodeInput::value(TaggedValue::Graphic(Default::default()), true),
|
||||||
NodeInput::value(TaggedValue::BooleanOperation(path_bool::BooleanOperation::Union), false),
|
NodeInput::value(TaggedValue::BooleanOperation(vector::misc::BooleanOperation::Union), false),
|
||||||
],
|
],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@@ -2191,9 +2192,10 @@ fn static_input_properties() -> InputProperties {
|
|||||||
true
|
true
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(vec![LayoutGroup::Row {
|
Ok(vec![LayoutGroup::row(node_properties::number_widget(
|
||||||
widgets: node_properties::number_widget(ParameterWidgetsInfo::new(node_id, index, blank_assist, context), number_input),
|
ParameterWidgetsInfo::new(node_id, index, blank_assist, context),
|
||||||
}])
|
number_input,
|
||||||
|
))])
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
map.insert(
|
map.insert(
|
||||||
@@ -2227,10 +2229,12 @@ fn static_input_properties() -> InputProperties {
|
|||||||
number_input = number_input.step(number_step);
|
number_input = number_input.step(number_step);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(vec![LayoutGroup::Row {
|
// NOTE: The bool input MUST be at the input index directly before the f64 input!
|
||||||
// NOTE: The bool input MUST be at the input index directly before the f64 input!
|
Ok(vec![LayoutGroup::row(node_properties::optional_f64_widget(
|
||||||
widgets: node_properties::optional_f64_widget(ParameterWidgetsInfo::new(node_id, index, false, context), index - 1, number_input),
|
ParameterWidgetsInfo::new(node_id, index, false, context),
|
||||||
}])
|
index - 1,
|
||||||
|
number_input,
|
||||||
|
))])
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
map.insert(
|
map.insert(
|
||||||
@@ -2298,7 +2302,7 @@ fn static_input_properties() -> InputProperties {
|
|||||||
"noise_properties_noise_type".to_string(),
|
"noise_properties_noise_type".to_string(),
|
||||||
Box::new(|node_id, index, context| {
|
Box::new(|node_id, index, context| {
|
||||||
let noise_type_row = enum_choice::<NoiseType>().for_socket(ParameterWidgetsInfo::new(node_id, index, true, context)).property_row();
|
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 { widgets: Vec::new() }])
|
Ok(vec![noise_type_row, LayoutGroup::row(Vec::new())])
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
map.insert(
|
map.insert(
|
||||||
@@ -2320,7 +2324,7 @@ fn static_input_properties() -> InputProperties {
|
|||||||
ParameterWidgetsInfo::new(node_id, index, true, context),
|
ParameterWidgetsInfo::new(node_id, index, true, context),
|
||||||
NumberInput::default().min(0.).disabled(!coherent_noise_active || !domain_warp_active),
|
NumberInput::default().min(0.).disabled(!coherent_noise_active || !domain_warp_active),
|
||||||
);
|
);
|
||||||
Ok(vec![domain_warp_amplitude.into(), LayoutGroup::Row { widgets: Vec::new() }])
|
Ok(vec![domain_warp_amplitude.into(), LayoutGroup::row(Vec::new())])
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
map.insert(
|
map.insert(
|
||||||
@@ -2408,7 +2412,7 @@ fn static_input_properties() -> InputProperties {
|
|||||||
.range_max(Some(10.))
|
.range_max(Some(10.))
|
||||||
.disabled(!ping_pong_active || !coherent_noise_active || !fractal_active || domain_warp_only_fractal_type_wrongly_active),
|
.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 { widgets: Vec::new() }])
|
Ok(vec![fractal_ping_pong_strength.into(), LayoutGroup::row(Vec::new())])
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
map.insert(
|
map.insert(
|
||||||
@@ -2504,7 +2508,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
|
// Skew has a custom override that maps to degrees
|
||||||
@@ -2548,24 +2552,20 @@ fn static_input_properties() -> InputProperties {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(vec![LayoutGroup::Row { widgets }])
|
Ok(vec![LayoutGroup::row(widgets)])
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
map.insert(
|
map.insert(
|
||||||
"text_area".to_string(),
|
"text_area".to_string(),
|
||||||
Box::new(|node_id, index, context| {
|
Box::new(|node_id, index, context| Ok(vec![LayoutGroup::row(node_properties::text_area_widget(ParameterWidgetsInfo::new(node_id, index, true, context)))])),
|
||||||
Ok(vec![LayoutGroup::Row {
|
|
||||||
widgets: node_properties::text_area_widget(ParameterWidgetsInfo::new(node_id, index, true, context)),
|
|
||||||
}])
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
map.insert(
|
map.insert(
|
||||||
"text_font".to_string(),
|
"text_font".to_string(),
|
||||||
Box::new(|node_id, index, context| {
|
Box::new(|node_id, index, context| {
|
||||||
let (font, style) = node_properties::font_inputs(ParameterWidgetsInfo::new(node_id, index, true, context));
|
let (font, style) = node_properties::font_inputs(ParameterWidgetsInfo::new(node_id, index, true, context));
|
||||||
let mut result = vec![LayoutGroup::Row { widgets: font }];
|
let mut result = vec![LayoutGroup::row(font)];
|
||||||
if let Some(style) = style {
|
if let Some(style) = style {
|
||||||
result.push(LayoutGroup::Row { widgets: style });
|
result.push(LayoutGroup::row(style));
|
||||||
}
|
}
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -847,7 +847,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.context_menu = Some(ContextMenuInformation {
|
self.context_menu = Some(ContextMenuInformation {
|
||||||
context_menu_coordinates: (node_graph_point + node_graph_shift).as_ivec2(),
|
context_menu_coordinates: (node_graph_point + node_graph_shift).as_ivec2().into(),
|
||||||
context_menu_data,
|
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();
|
let compatible_type = network_interface.output_type(&output_connector, selection_network_path).add_node_string();
|
||||||
|
|
||||||
self.context_menu = Some(ContextMenuInformation {
|
self.context_menu = Some(ContextMenuInformation {
|
||||||
context_menu_coordinates: (point + node_graph_shift).as_ivec2(),
|
context_menu_coordinates: (point + node_graph_shift).as_ivec2().into(),
|
||||||
context_menu_data: ContextMenuData::CreateNode { compatible_type },
|
context_menu_data: ContextMenuData::CreateNode { compatible_type },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2050,8 +2050,8 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
|||||||
responses.add(FrontendMessage::UpdateImportsExports {
|
responses.add(FrontendMessage::UpdateImportsExports {
|
||||||
imports,
|
imports,
|
||||||
exports,
|
exports,
|
||||||
import_position,
|
import_position: import_position.into(),
|
||||||
export_position,
|
export_position: export_position.into(),
|
||||||
add_import_export,
|
add_import_export,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -2181,7 +2181,7 @@ impl NodeGraphMessageHandler {
|
|||||||
|
|
||||||
let mut widgets = vec![
|
let mut widgets = vec![
|
||||||
PopoverButton::new()
|
PopoverButton::new()
|
||||||
.icon(Some("Node".to_string()))
|
.icon("Node")
|
||||||
.tooltip_label("New Node")
|
.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_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))
|
.tooltip_shortcut(action_shortcut_manual!(Key::MouseRight))
|
||||||
@@ -2222,7 +2222,7 @@ impl NodeGraphMessageHandler {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.widget_instance();
|
.widget_instance();
|
||||||
Layout(vec![LayoutGroup::Row { widgets: vec![node_chooser] }])
|
Layout(vec![LayoutGroup::row(vec![node_chooser])])
|
||||||
})
|
})
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
//
|
//
|
||||||
@@ -2252,14 +2252,14 @@ impl NodeGraphMessageHandler {
|
|||||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
//
|
//
|
||||||
IconButton::new(if selection_all_locked { "PadlockLocked" } else { "PadlockUnlocked" }, 24)
|
IconButton::new(if selection_all_locked { "PadlockLocked" } else { "PadlockUnlocked" }, 24)
|
||||||
.hover_icon(Some((if selection_all_locked { "PadlockUnlocked" } else { "PadlockLocked" }).into()))
|
.hover_icon(if selection_all_locked { "PadlockUnlocked" } else { "PadlockLocked" })
|
||||||
.tooltip_label(if selection_all_locked { "Unlock Selected" } else { "Lock Selected" })
|
.tooltip_label(if selection_all_locked { "Unlock Selected" } else { "Lock Selected" })
|
||||||
.tooltip_shortcut(action_shortcut!(NodeGraphMessageDiscriminant::ToggleSelectedLocked))
|
.tooltip_shortcut(action_shortcut!(NodeGraphMessageDiscriminant::ToggleSelectedLocked))
|
||||||
.on_update(|_| NodeGraphMessage::ToggleSelectedLocked.into())
|
.on_update(|_| NodeGraphMessage::ToggleSelectedLocked.into())
|
||||||
.disabled(!has_selection || !selection_includes_layers)
|
.disabled(!has_selection || !selection_includes_layers)
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
IconButton::new(if selection_all_visible { "EyeVisible" } else { "EyeHidden" }, 24)
|
IconButton::new(if selection_all_visible { "EyeVisible" } else { "EyeHidden" }, 24)
|
||||||
.hover_icon(Some((if selection_all_visible { "EyeHide" } else { "EyeShow" }).into()))
|
.hover_icon(if selection_all_visible { "EyeHide" } else { "EyeShow" })
|
||||||
.tooltip_label(if selection_all_visible { "Hide Selected" } else { "Show Selected" })
|
.tooltip_label(if selection_all_visible { "Hide Selected" } else { "Show Selected" })
|
||||||
.tooltip_shortcut(action_shortcut!(NodeGraphMessageDiscriminant::ToggleSelectedVisibility))
|
.tooltip_shortcut(action_shortcut!(NodeGraphMessageDiscriminant::ToggleSelectedVisibility))
|
||||||
.on_update(|_| NodeGraphMessage::ToggleSelectedVisibility.into())
|
.on_update(|_| NodeGraphMessage::ToggleSelectedVisibility.into())
|
||||||
@@ -2286,7 +2286,7 @@ impl NodeGraphMessageHandler {
|
|||||||
// If only one node is selected then show the preview or stop previewing button
|
// If only one node is selected then show the preview or stop previewing button
|
||||||
if let Some(node_id) = previewing {
|
if let Some(node_id) = previewing {
|
||||||
let button = TextButton::new("End Preview")
|
let button = TextButton::new("End Preview")
|
||||||
.icon(Some("FrameAll".to_string()))
|
.icon("FrameAll")
|
||||||
.tooltip_description("Restore preview to the graph output.")
|
.tooltip_description("Restore preview to the graph output.")
|
||||||
.on_update(move |_| NodeGraphMessage::TogglePreview { node_id }.into())
|
.on_update(move |_| NodeGraphMessage::TogglePreview { node_id }.into())
|
||||||
.widget_instance();
|
.widget_instance();
|
||||||
@@ -2298,7 +2298,7 @@ impl NodeGraphMessageHandler {
|
|||||||
.any(|export| matches!(export, NodeInput::Node { node_id: export_node_id, .. } if *export_node_id == node_id));
|
.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 {
|
if selection_is_not_already_the_output && no_other_selections {
|
||||||
let button = TextButton::new("Preview")
|
let button = TextButton::new("Preview")
|
||||||
.icon(Some("FrameAll".to_string()))
|
.icon("FrameAll")
|
||||||
.tooltip_label("Preview")
|
.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_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))
|
.tooltip_shortcut(action_shortcut_manual!(Key::Alt, Key::MouseLeft))
|
||||||
@@ -2323,7 +2323,7 @@ impl NodeGraphMessageHandler {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.widgets[0] = LayoutGroup::Row { widgets };
|
self.widgets[0] = LayoutGroup::row(widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_graph_bar_right(
|
fn update_graph_bar_right(
|
||||||
@@ -2357,15 +2357,15 @@ impl NodeGraphMessageHandler {
|
|||||||
widgets.extend([
|
widgets.extend([
|
||||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
TextButton::new("Node Graph")
|
TextButton::new("Node Graph")
|
||||||
.icon(Some("GraphViewOpen".into()))
|
.icon("GraphViewOpen")
|
||||||
.hover_icon(Some("GraphViewClosed".into()))
|
.hover_icon("GraphViewClosed")
|
||||||
.tooltip_label("Hide Node Graph")
|
.tooltip_label("Hide Node Graph")
|
||||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::GraphViewOverlayToggle))
|
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::GraphViewOverlayToggle))
|
||||||
.on_update(move |_| DocumentMessage::GraphViewOverlayToggle.into())
|
.on_update(move |_| DocumentMessage::GraphViewOverlayToggle.into())
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self.widgets[1] = LayoutGroup::Row { widgets };
|
self.widgets[1] = LayoutGroup::row(widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Collate the properties panel sections for a node graph
|
/// Collate the properties panel sections for a node graph
|
||||||
@@ -2407,25 +2407,23 @@ impl NodeGraphMessageHandler {
|
|||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
if let [node_id] = *nodes.as_slice() {
|
if let [node_id] = *nodes.as_slice() {
|
||||||
properties.push(LayoutGroup::Row {
|
properties.push(LayoutGroup::row(vec![
|
||||||
widgets: vec![
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_instance(),
|
||||||
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
TextInput::new(context.network_interface.display_name(&node_id, context.selection_network_path))
|
||||||
TextInput::new(context.network_interface.display_name(&node_id, context.selection_network_path))
|
.tooltip_description("Name of the selected node.")
|
||||||
.tooltip_description("Name of the selected node.")
|
.on_update(move |text_input| {
|
||||||
.on_update(move |text_input| {
|
NodeGraphMessage::SetDisplayName {
|
||||||
NodeGraphMessage::SetDisplayName {
|
node_id,
|
||||||
node_id,
|
alias: text_input.value.clone(),
|
||||||
alias: text_input.value.clone(),
|
skip_adding_history_step: false,
|
||||||
skip_adding_history_step: false,
|
}
|
||||||
}
|
.into()
|
||||||
.into()
|
})
|
||||||
})
|
.widget_instance(),
|
||||||
.widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
]));
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
properties.extend(selected_nodes);
|
properties.extend(selected_nodes);
|
||||||
@@ -2435,18 +2433,16 @@ impl NodeGraphMessageHandler {
|
|||||||
|
|
||||||
// TODO: Display properties for encapsulating node when no nodes are selected in a nested network
|
// 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
|
// This may require store a separate path for the properties panel
|
||||||
let mut properties = vec![LayoutGroup::Row {
|
let mut properties = vec![LayoutGroup::row(vec![
|
||||||
widgets: vec![
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
IconLabel::new("File").tooltip_description("Name of the current document.").widget_instance(),
|
||||||
IconLabel::new("File").tooltip_description("Name of the current document.").widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
TextInput::new(context.document_name)
|
||||||
TextInput::new(context.document_name)
|
.tooltip_description("Name of the current document.")
|
||||||
.tooltip_description("Name of the current document.")
|
.on_update(|text_input| DocumentMessage::RenameDocument { new_name: text_input.value.clone() }.into())
|
||||||
.on_update(|text_input| DocumentMessage::RenameDocument { new_name: text_input.value.clone() }.into())
|
.widget_instance(),
|
||||||
.widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
])];
|
||||||
],
|
|
||||||
}];
|
|
||||||
|
|
||||||
let Some(network) = context.network_interface.nested_network(context.selection_network_path) else {
|
let Some(network) = context.network_interface.nested_network(context.selection_network_path) else {
|
||||||
warn!("No network in collate_properties");
|
warn!("No network in collate_properties");
|
||||||
@@ -2482,50 +2478,48 @@ impl NodeGraphMessageHandler {
|
|||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut layer_properties = vec![LayoutGroup::Row {
|
let mut layer_properties = vec![LayoutGroup::row(vec![
|
||||||
widgets: vec![
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_instance(),
|
||||||
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
TextInput::new(context.network_interface.display_name(&layer, context.selection_network_path))
|
||||||
TextInput::new(context.network_interface.display_name(&layer, context.selection_network_path))
|
.tooltip_description("Name of the selected layer.")
|
||||||
.tooltip_description("Name of the selected layer.")
|
.on_update(move |text_input| {
|
||||||
.on_update(move |text_input| {
|
NodeGraphMessage::SetDisplayName {
|
||||||
NodeGraphMessage::SetDisplayName {
|
node_id: layer,
|
||||||
node_id: layer,
|
alias: text_input.value.clone(),
|
||||||
alias: text_input.value.clone(),
|
skip_adding_history_step: false,
|
||||||
skip_adding_history_step: false,
|
}
|
||||||
}
|
.into()
|
||||||
.into()
|
})
|
||||||
})
|
.widget_instance(),
|
||||||
.widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
PopoverButton::new()
|
||||||
PopoverButton::new()
|
.icon("Node")
|
||||||
.icon(Some("Node".to_string()))
|
.tooltip_description("Add an operation to the end of this layer's chain of nodes.")
|
||||||
.tooltip_description("Add an operation to the end of this layer's chain of nodes.")
|
.popover_layout({
|
||||||
.popover_layout({
|
let compatible_type = context
|
||||||
let compatible_type = context
|
.network_interface
|
||||||
.network_interface
|
.upstream_output_connector(&InputConnector::node(layer, 1), &[])
|
||||||
.upstream_output_connector(&InputConnector::node(layer, 1), &[])
|
.and_then(|upstream_output| context.network_interface.output_type(&upstream_output, &[]).add_node_string());
|
||||||
.and_then(|upstream_output| context.network_interface.output_type(&upstream_output, &[]).add_node_string());
|
|
||||||
|
|
||||||
let mut node_chooser = NodeCatalog::new();
|
let mut node_chooser = NodeCatalog::new();
|
||||||
node_chooser.intial_search = compatible_type.unwrap_or("".to_string());
|
node_chooser.intial_search = compatible_type.unwrap_or("".to_string());
|
||||||
|
|
||||||
let node_chooser = node_chooser
|
let node_chooser = node_chooser
|
||||||
.on_update(move |node_type| {
|
.on_update(move |node_type| {
|
||||||
NodeGraphMessage::CreateNodeInLayerWithTransaction {
|
NodeGraphMessage::CreateNodeInLayerWithTransaction {
|
||||||
node_type: node_type.clone(),
|
node_type: node_type.clone(),
|
||||||
layer: LayerNodeIdentifier::new_unchecked(layer),
|
layer: LayerNodeIdentifier::new_unchecked(layer),
|
||||||
}
|
}
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
.widget_instance();
|
.widget_instance();
|
||||||
Layout(vec![LayoutGroup::Row { widgets: vec![node_chooser] }])
|
Layout(vec![LayoutGroup::row(vec![node_chooser])])
|
||||||
})
|
})
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).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)
|
// 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
|
let node_properties = context
|
||||||
@@ -2651,7 +2645,7 @@ impl NodeGraphMessageHandler {
|
|||||||
exposed_outputs,
|
exposed_outputs,
|
||||||
primary_output_connected_to_layer,
|
primary_output_connected_to_layer,
|
||||||
primary_input_connected_to_layer,
|
primary_input_connected_to_layer,
|
||||||
position,
|
position: position.into(),
|
||||||
previewed,
|
previewed,
|
||||||
visible,
|
visible,
|
||||||
locked,
|
locked,
|
||||||
@@ -2695,6 +2689,7 @@ impl NodeGraphMessageHandler {
|
|||||||
if network_interface.is_layer(&error_node, breadcrumb_network_path) {
|
if network_interface.is_layer(&error_node, breadcrumb_network_path) {
|
||||||
position += IVec2::new(12, -12)
|
position += IVec2::new(12, -12)
|
||||||
}
|
}
|
||||||
|
let position = position.into();
|
||||||
|
|
||||||
Some(NodeGraphErrorDiagnostic { position, error })
|
Some(NodeGraphErrorDiagnostic { position, error })
|
||||||
}
|
}
|
||||||
@@ -2841,7 +2836,7 @@ impl Default for NodeGraphMessageHandler {
|
|||||||
Self {
|
Self {
|
||||||
network: Vec::new(),
|
network: Vec::new(),
|
||||||
has_selection: false,
|
has_selection: false,
|
||||||
widgets: [LayoutGroup::Row { widgets: Vec::new() }, LayoutGroup::Row { widgets: Vec::new() }],
|
widgets: [LayoutGroup::row(Vec::new()), LayoutGroup::row(Vec::new())],
|
||||||
drag_start: None,
|
drag_start: None,
|
||||||
begin_dragging: false,
|
begin_dragging: false,
|
||||||
node_has_moved_in_drag: false,
|
node_has_moved_in_drag: false,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ use graph_craft::{Type, concrete};
|
|||||||
use graphene_std::NodeInputDecleration;
|
use graphene_std::NodeInputDecleration;
|
||||||
use graphene_std::animation::RealTimeMode;
|
use graphene_std::animation::RealTimeMode;
|
||||||
use graphene_std::extract_xy::XY;
|
use graphene_std::extract_xy::XY;
|
||||||
use graphene_std::path_bool::BooleanOperation;
|
|
||||||
use graphene_std::raster::curve::Curve;
|
use graphene_std::raster::curve::Curve;
|
||||||
use graphene_std::raster::{
|
use graphene_std::raster::{
|
||||||
BlendMode, CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, LuminanceCalculation, NoiseType, RedGreenBlue, RedGreenBlueAlpha, RelativeAbsolute,
|
BlendMode, CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, LuminanceCalculation, NoiseType, RedGreenBlue, RedGreenBlueAlpha, RelativeAbsolute,
|
||||||
@@ -26,12 +25,13 @@ use graphene_std::table::{Table, TableRow};
|
|||||||
use graphene_std::text::{Font, TextAlign};
|
use graphene_std::text::{Font, TextAlign};
|
||||||
use graphene_std::transform::{Footprint, ReferencePoint, Transform};
|
use graphene_std::transform::{Footprint, ReferencePoint, Transform};
|
||||||
use graphene_std::vector::QRCodeErrorCorrectionLevel;
|
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::misc::{ArcType, CentroidType, ExtrudeJoiningAlgorithm, GridType, MergeByDistanceAlgorithm, PointSpacingType, RowsOrColumns, SpiralType};
|
||||||
use graphene_std::vector::style::{Fill, FillChoice, FillType, GradientStops, GradientType, PaintOrder, StrokeAlign, StrokeCap, StrokeJoin};
|
use graphene_std::vector::style::{Fill, FillChoice, FillType, GradientStops, GradientType, PaintOrder, StrokeAlign, StrokeCap, StrokeJoin};
|
||||||
|
|
||||||
pub(crate) fn string_properties(text: &str) -> Vec<LayoutGroup> {
|
pub(crate) fn string_properties(text: &str) -> Vec<LayoutGroup> {
|
||||||
let widget = TextLabel::new(text).widget_instance();
|
let widget = TextLabel::new(text).widget_instance();
|
||||||
vec![LayoutGroup::Row { widgets: vec![widget] }]
|
vec![LayoutGroup::row(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 {
|
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,11 +538,7 @@ pub fn footprint_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let widgets = [
|
let widgets = [LayoutGroup::row(location_widgets), LayoutGroup::row(scale_widgets), LayoutGroup::row(resolution_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");
|
let (last, rest) = widgets.split_last().expect("Footprint widget should return multiple rows");
|
||||||
*extra_widgets = rest.to_vec();
|
*extra_widgets = rest.to_vec();
|
||||||
last.clone()
|
last.clone()
|
||||||
@@ -651,13 +647,9 @@ pub fn transform_widget(parameter_widgets_info: ParameterWidgetsInfo, extra_widg
|
|||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
vec![
|
vec![LayoutGroup::row(location_widgets), LayoutGroup::row(rotation_widgets), LayoutGroup::row(scale_widgets)]
|
||||||
LayoutGroup::Row { widgets: location_widgets },
|
|
||||||
LayoutGroup::Row { widgets: rotation_widgets },
|
|
||||||
LayoutGroup::Row { widgets: scale_widgets },
|
|
||||||
]
|
|
||||||
} else {
|
} else {
|
||||||
vec![LayoutGroup::Row { widgets: location_widgets }]
|
vec![LayoutGroup::row(location_widgets)]
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some((last, rest)) = widgets.split_last() {
|
if let Some((last, rest)) = widgets.split_last() {
|
||||||
@@ -676,7 +668,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(document_node) = document_node else { return LayoutGroup::default() };
|
||||||
let Some(input) = document_node.inputs.get(index) else {
|
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.");
|
log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||||
return LayoutGroup::Row { widgets: vec![] };
|
return LayoutGroup::row(vec![]);
|
||||||
};
|
};
|
||||||
match input.as_non_exposed_value() {
|
match input.as_non_exposed_value() {
|
||||||
Some(&TaggedValue::DVec2(dvec2)) => {
|
Some(&TaggedValue::DVec2(dvec2)) => {
|
||||||
@@ -730,7 +722,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> {
|
pub fn array_of_number_widget(parameter_widgets_info: ParameterWidgetsInfo, text_input: TextInput) -> Vec<WidgetInstance> {
|
||||||
@@ -1101,7 +1093,7 @@ pub fn blend_mode_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Layout
|
|||||||
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
||||||
let Some(input) = document_node.inputs.get(index) else {
|
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.");
|
log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||||
return LayoutGroup::Row { widgets: vec![] };
|
return LayoutGroup::row(vec![]);
|
||||||
};
|
};
|
||||||
if let Some(&TaggedValue::BlendMode(blend_mode)) = input.as_non_exposed_value() {
|
if let Some(&TaggedValue::BlendMode(blend_mode)) = input.as_non_exposed_value() {
|
||||||
let entries = BlendMode::list_svg_subset()
|
let entries = BlendMode::list_svg_subset()
|
||||||
@@ -1126,7 +1118,7 @@ pub fn blend_mode_widget(parameter_widgets_info: ParameterWidgetsInfo) -> Layout
|
|||||||
.widget_instance(),
|
.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 {
|
pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button: ColorInput) -> LayoutGroup {
|
||||||
@@ -1137,7 +1129,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
|||||||
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
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
|
// 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 {
|
let NodeInput::Value { tagged_value, exposed: false } = &document_node.inputs[index] else {
|
||||||
return LayoutGroup::Row { widgets };
|
return LayoutGroup::row(widgets);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add a separator
|
// Add a separator
|
||||||
@@ -1176,7 +1168,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
|
|||||||
x => warn!("Color {x:?}"),
|
x => warn!("Color {x:?}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutGroup::Row { widgets }
|
LayoutGroup::row(widgets)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn font_widget(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup {
|
pub fn font_widget(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup {
|
||||||
@@ -1192,7 +1184,7 @@ pub fn curve_widget(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup
|
|||||||
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
let Some(document_node) = document_node else { return LayoutGroup::default() };
|
||||||
let Some(input) = document_node.inputs.get(index) else {
|
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.");
|
log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||||
return LayoutGroup::Row { widgets: vec![] };
|
return LayoutGroup::row(vec![]);
|
||||||
};
|
};
|
||||||
if let Some(TaggedValue::Curve(curve)) = &input.as_non_exposed_value() {
|
if let Some(TaggedValue::Curve(curve)) = &input.as_non_exposed_value() {
|
||||||
widgets.extend_from_slice(&[
|
widgets.extend_from_slice(&[
|
||||||
@@ -1203,7 +1195,7 @@ pub fn curve_widget(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup
|
|||||||
.widget_instance(),
|
.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> {
|
pub fn get_document_node<'a>(node_id: NodeId, context: &'a NodePropertiesContext<'a>) -> Result<&'a DocumentNode, String> {
|
||||||
@@ -1306,10 +1298,10 @@ pub(crate) fn brightness_contrast_properties(node_id: NodeId, context: &mut Node
|
|||||||
.range_max(Some(100.)),
|
.range_max(Some(100.)),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut layout = vec![LayoutGroup::Row { widgets: brightness }, LayoutGroup::Row { widgets: contrast }];
|
let mut layout = vec![LayoutGroup::row(brightness), LayoutGroup::row(contrast)];
|
||||||
if includes_use_classic {
|
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
|
// 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 { widgets: use_classic });
|
layout.push(LayoutGroup::row(use_classic));
|
||||||
}
|
}
|
||||||
|
|
||||||
layout
|
layout
|
||||||
@@ -1358,18 +1350,13 @@ 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);
|
let constant = number_widget(ParameterWidgetsInfo::new(node_id, constant_output_index, true, context), number_input);
|
||||||
|
|
||||||
// Monochrome
|
// Monochrome
|
||||||
let mut layout = vec![LayoutGroup::Row { widgets: is_monochrome }];
|
let mut layout = vec![LayoutGroup::row(is_monochrome)];
|
||||||
// Output channel choice
|
// Output channel choice
|
||||||
if !is_monochrome_value {
|
if !is_monochrome_value {
|
||||||
layout.push(output_channel);
|
layout.push(output_channel);
|
||||||
}
|
}
|
||||||
// Channel values
|
// Channel values
|
||||||
layout.extend([
|
layout.extend([LayoutGroup::row(red), LayoutGroup::row(green), LayoutGroup::row(blue), LayoutGroup::row(constant)]);
|
||||||
LayoutGroup::Row { widgets: red },
|
|
||||||
LayoutGroup::Row { widgets: green },
|
|
||||||
LayoutGroup::Row { widgets: blue },
|
|
||||||
LayoutGroup::Row { widgets: constant },
|
|
||||||
]);
|
|
||||||
layout
|
layout
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1422,10 +1409,10 @@ pub(crate) fn selective_color_properties(node_id: NodeId, context: &mut NodeProp
|
|||||||
// Colors choice
|
// Colors choice
|
||||||
colors,
|
colors,
|
||||||
// CMYK
|
// CMYK
|
||||||
LayoutGroup::Row { widgets: cyan },
|
LayoutGroup::row(cyan),
|
||||||
LayoutGroup::Row { widgets: magenta },
|
LayoutGroup::row(magenta),
|
||||||
LayoutGroup::Row { widgets: yellow },
|
LayoutGroup::row(yellow),
|
||||||
LayoutGroup::Row { widgets: black },
|
LayoutGroup::row(black),
|
||||||
// Mode
|
// Mode
|
||||||
mode,
|
mode,
|
||||||
]
|
]
|
||||||
@@ -1458,12 +1445,10 @@ pub(crate) fn grid_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||||||
widgets.push(spacing);
|
widgets.push(spacing);
|
||||||
}
|
}
|
||||||
GridType::Isometric => {
|
GridType::Isometric => {
|
||||||
let spacing = LayoutGroup::Row {
|
let spacing = LayoutGroup::row(number_widget(
|
||||||
widgets: number_widget(
|
ParameterWidgetsInfo::new(node_id, SpacingInput::<f64>::INDEX, true, context),
|
||||||
ParameterWidgetsInfo::new(node_id, SpacingInput::<f64>::INDEX, true, context),
|
NumberInput::default().label("H").min(0.).unit(" px"),
|
||||||
NumberInput::default().label("H").min(0.).unit(" px"),
|
));
|
||||||
),
|
|
||||||
};
|
|
||||||
let angles = vec2_widget(ParameterWidgetsInfo::new(node_id, AnglesInput::INDEX, true, context), "", "", "°", None, false);
|
let angles = vec2_widget(ParameterWidgetsInfo::new(node_id, AnglesInput::INDEX, true, context), "", "", "°", None, false);
|
||||||
widgets.extend([spacing, angles]);
|
widgets.extend([spacing, angles]);
|
||||||
}
|
}
|
||||||
@@ -1473,7 +1458,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 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.));
|
let rows = number_widget(ParameterWidgetsInfo::new(node_id, RowsInput::INDEX, true, context), NumberInput::default().min(1.));
|
||||||
|
|
||||||
widgets.extend([LayoutGroup::Row { widgets: columns }, LayoutGroup::Row { widgets: rows }]);
|
widgets.extend([LayoutGroup::row(columns), LayoutGroup::row(rows)]);
|
||||||
|
|
||||||
widgets
|
widgets
|
||||||
}
|
}
|
||||||
@@ -1487,7 +1472,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 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 start_angle = number_widget(ParameterWidgetsInfo::new(node_id, StartAngleInput::INDEX, true, context), NumberInput::default().unit("°"));
|
||||||
|
|
||||||
let mut widgets = vec![spiral_type, LayoutGroup::Row { widgets: turns }, LayoutGroup::Row { widgets: start_angle }];
|
let mut widgets = vec![spiral_type, LayoutGroup::row(turns), LayoutGroup::row(start_angle)];
|
||||||
|
|
||||||
let document_node = match get_document_node(node_id, context) {
|
let document_node = match get_document_node(node_id, context) {
|
||||||
Ok(document_node) => document_node,
|
Ok(document_node) => document_node,
|
||||||
@@ -1504,24 +1489,28 @@ 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() {
|
if let Some(&TaggedValue::SpiralType(spiral_type)) = spiral_type_input.as_non_exposed_value() {
|
||||||
match spiral_type {
|
match spiral_type {
|
||||||
SpiralType::Archimedean => {
|
SpiralType::Archimedean => {
|
||||||
let inner_radius = LayoutGroup::Row {
|
let inner_radius = LayoutGroup::row(number_widget(
|
||||||
widgets: number_widget(ParameterWidgetsInfo::new(node_id, InnerRadiusInput::INDEX, true, context), NumberInput::default().min(0.).unit(" px")),
|
ParameterWidgetsInfo::new(node_id, InnerRadiusInput::INDEX, true, context),
|
||||||
};
|
NumberInput::default().min(0.).unit(" px"),
|
||||||
|
));
|
||||||
|
|
||||||
let outer_radius = LayoutGroup::Row {
|
let outer_radius = LayoutGroup::row(number_widget(
|
||||||
widgets: number_widget(ParameterWidgetsInfo::new(node_id, OuterRadiusInput::INDEX, true, context), NumberInput::default().unit(" px")),
|
ParameterWidgetsInfo::new(node_id, OuterRadiusInput::INDEX, true, context),
|
||||||
};
|
NumberInput::default().unit(" px"),
|
||||||
|
));
|
||||||
|
|
||||||
widgets.extend([inner_radius, outer_radius]);
|
widgets.extend([inner_radius, outer_radius]);
|
||||||
}
|
}
|
||||||
SpiralType::Logarithmic => {
|
SpiralType::Logarithmic => {
|
||||||
let inner_radius = LayoutGroup::Row {
|
let inner_radius = LayoutGroup::row(number_widget(
|
||||||
widgets: number_widget(ParameterWidgetsInfo::new(node_id, InnerRadiusInput::INDEX, true, context), NumberInput::default().min(0.).unit(" px")),
|
ParameterWidgetsInfo::new(node_id, InnerRadiusInput::INDEX, true, context),
|
||||||
};
|
NumberInput::default().min(0.).unit(" px"),
|
||||||
|
));
|
||||||
|
|
||||||
let outer_radius = LayoutGroup::Row {
|
let outer_radius = LayoutGroup::row(number_widget(
|
||||||
widgets: number_widget(ParameterWidgetsInfo::new(node_id, OuterRadiusInput::INDEX, true, context), NumberInput::default().min(0.1).unit(" px")),
|
ParameterWidgetsInfo::new(node_id, OuterRadiusInput::INDEX, true, context),
|
||||||
};
|
NumberInput::default().min(0.1).unit(" px"),
|
||||||
|
));
|
||||||
|
|
||||||
widgets.extend([inner_radius, outer_radius]);
|
widgets.extend([inner_radius, outer_radius]);
|
||||||
}
|
}
|
||||||
@@ -1533,7 +1522,7 @@ pub(crate) fn spiral_properties(node_id: NodeId, context: &mut NodePropertiesCon
|
|||||||
NumberInput::default().min(1.).max(180.).unit("°"),
|
NumberInput::default().min(1.).max(180.).unit("°"),
|
||||||
);
|
);
|
||||||
|
|
||||||
widgets.push(LayoutGroup::Row { widgets: angular_resolution });
|
widgets.push(LayoutGroup::row(angular_resolution));
|
||||||
|
|
||||||
widgets
|
widgets
|
||||||
}
|
}
|
||||||
@@ -1574,13 +1563,13 @@ pub(crate) fn sample_polyline_properties(node_id: NodeId, context: &mut NodeProp
|
|||||||
vec![
|
vec![
|
||||||
spacing.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_SPACING),
|
spacing.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_SPACING),
|
||||||
match current_spacing {
|
match current_spacing {
|
||||||
Some(TaggedValue::PointSpacingType(PointSpacingType::Separation)) => LayoutGroup::Row { widgets: separation }.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_SEPARATION),
|
Some(TaggedValue::PointSpacingType(PointSpacingType::Separation)) => LayoutGroup::row(separation).with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_SEPARATION),
|
||||||
Some(TaggedValue::PointSpacingType(PointSpacingType::Quantity)) => LayoutGroup::Row { widgets: quantity }.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_QUANTITY),
|
Some(TaggedValue::PointSpacingType(PointSpacingType::Quantity)) => LayoutGroup::row(quantity).with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_QUANTITY),
|
||||||
_ => LayoutGroup::Row { widgets: vec![] },
|
_ => LayoutGroup::row(vec![]),
|
||||||
},
|
},
|
||||||
LayoutGroup::Row { widgets: start_offset }.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_START_OFFSET),
|
LayoutGroup::row(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(stop_offset).with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_STOP_OFFSET),
|
||||||
LayoutGroup::Row { widgets: adaptive_spacing }.with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_ADAPTIVE_SPACING),
|
LayoutGroup::row(adaptive_spacing).with_tooltip_description(SAMPLE_POLYLINE_DESCRIPTION_ADAPTIVE_SPACING),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1594,11 +1583,7 @@ pub(crate) fn exposure_properties(node_id: NodeId, context: &mut NodePropertiesC
|
|||||||
NumberInput::default().min(0.01).max(9.99).increment_step(0.1),
|
NumberInput::default().min(0.01).max(9.99).increment_step(0.1),
|
||||||
);
|
);
|
||||||
|
|
||||||
vec![
|
vec![LayoutGroup::row(exposure), LayoutGroup::row(offset), LayoutGroup::row(gamma_correction)]
|
||||||
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> {
|
pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||||
@@ -1722,11 +1707,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());
|
let clamped = bool_widget(ParameterWidgetsInfo::new(node_id, ClampedInput::INDEX, true, context), CheckboxInput::default());
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
LayoutGroup::Row { widgets: size_x },
|
LayoutGroup::row(size_x),
|
||||||
LayoutGroup::Row { widgets: size_y },
|
LayoutGroup::row(size_y),
|
||||||
LayoutGroup::Row { widgets: corner_radius_row_1 },
|
LayoutGroup::row(corner_radius_row_1),
|
||||||
LayoutGroup::Row { widgets: corner_radius_row_2 },
|
LayoutGroup::row(corner_radius_row_2),
|
||||||
LayoutGroup::Row { widgets: clamped },
|
LayoutGroup::row(clamped),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1825,14 +1810,7 @@ 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 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);
|
let pinned = context.network_interface.is_pinned(&node_id, context.selection_network_path);
|
||||||
|
|
||||||
LayoutGroup::Section {
|
LayoutGroup::section(name, description, visible, pinned, node_id.0, Layout(layout))
|
||||||
name,
|
|
||||||
description,
|
|
||||||
visible,
|
|
||||||
pinned,
|
|
||||||
id: node_id.0,
|
|
||||||
layout: Layout(layout),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fill Node Widgets LayoutGroup
|
/// Fill Node Widgets LayoutGroup
|
||||||
@@ -1856,7 +1834,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||||||
) {
|
) {
|
||||||
(fill, backup_color, backup_gradient)
|
(fill, backup_color, backup_gradient)
|
||||||
} else {
|
} else {
|
||||||
return vec![LayoutGroup::Row { widgets: widgets_first_row }];
|
return vec![LayoutGroup::row(widgets_first_row)];
|
||||||
};
|
};
|
||||||
let fill2 = fill.clone();
|
let fill2 = fill.clone();
|
||||||
let backup_color_fill: Fill = backup_color.clone().into();
|
let backup_color_fill: Fill = backup_color.clone().into();
|
||||||
@@ -1899,7 +1877,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
|
|||||||
.on_commit(commit_value)
|
.on_commit(commit_value)
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
);
|
);
|
||||||
let mut widgets = vec![LayoutGroup::Row { widgets: widgets_first_row }];
|
let mut widgets = vec![LayoutGroup::row(widgets_first_row)];
|
||||||
|
|
||||||
let fill_type_switch = {
|
let fill_type_switch = {
|
||||||
let mut row = vec![TextLabel::new("").widget_instance()];
|
let mut row = vec![TextLabel::new("").widget_instance()];
|
||||||
@@ -1942,7 +1920,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(),
|
RadioInput::new(entries).selected_index(Some(if fill.as_gradient().is_some() { 1 } else { 0 })).widget_instance(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
LayoutGroup::Row { widgets: row }
|
LayoutGroup::row(row)
|
||||||
};
|
};
|
||||||
widgets.push(fill_type_switch);
|
widgets.push(fill_type_switch);
|
||||||
|
|
||||||
@@ -2011,7 +1989,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(),
|
RadioInput::new(entries).selected_index(Some(gradient.gradient_type as u32)).widget_instance(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
widgets.push(LayoutGroup::Row { widgets: row });
|
widgets.push(LayoutGroup::row(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets
|
widgets
|
||||||
@@ -2069,14 +2047,14 @@ pub fn stroke_properties(node_id: NodeId, context: &mut NodePropertiesContext) -
|
|||||||
|
|
||||||
vec![
|
vec![
|
||||||
color,
|
color,
|
||||||
LayoutGroup::Row { widgets: weight },
|
LayoutGroup::row(weight),
|
||||||
align,
|
align,
|
||||||
cap,
|
cap,
|
||||||
join,
|
join,
|
||||||
LayoutGroup::Row { widgets: miter_limit },
|
LayoutGroup::row(miter_limit),
|
||||||
paint_order,
|
paint_order,
|
||||||
LayoutGroup::Row { widgets: dash_lengths },
|
LayoutGroup::row(dash_lengths),
|
||||||
LayoutGroup::Row { widgets: dash_offset },
|
LayoutGroup::row(dash_offset),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2106,7 +2084,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);
|
let miter_limit = number_widget(ParameterWidgetsInfo::new(node_id, MiterLimitInput::INDEX, true, context), number_input);
|
||||||
|
|
||||||
vec![LayoutGroup::Row { widgets: distance }, join, LayoutGroup::Row { widgets: miter_limit }]
|
vec![LayoutGroup::row(distance), join, LayoutGroup::row(miter_limit)]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn math_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
pub fn math_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||||
@@ -2158,9 +2136,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()];
|
let operand_a_hint = vec![TextLabel::new("(Operand A is the primary input)").widget_instance()];
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
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(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(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."#),
|
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."#),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2348,14 +2326,14 @@ pub mod choice {
|
|||||||
let ParameterWidgetsInfo { document_node, node_id, index, .. } = self.parameter_info;
|
let ParameterWidgetsInfo { document_node, node_id, index, .. } = self.parameter_info;
|
||||||
let Some(document_node) = document_node else {
|
let Some(document_node) = document_node else {
|
||||||
log::error!("Could not get document node when building property row for node {node_id:?}");
|
log::error!("Could not get document node when building property row for node {node_id:?}");
|
||||||
return LayoutGroup::Row { widgets: Vec::new() };
|
return LayoutGroup::row(Vec::new());
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut widgets = super::start_widgets(self.parameter_info);
|
let mut widgets = super::start_widgets(self.parameter_info);
|
||||||
|
|
||||||
let Some(input) = document_node.inputs.get(index) else {
|
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.");
|
log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||||
return LayoutGroup::Row { widgets: vec![] };
|
return LayoutGroup::row(vec![]);
|
||||||
};
|
};
|
||||||
|
|
||||||
let input: Option<W::Value> = input.as_non_exposed_value().and_then(|v| <&W::Value as TryFrom<&TaggedValue>>::try_from(v).ok()).cloned();
|
let input: Option<W::Value> = input.as_non_exposed_value().and_then(|v| <&W::Value as TryFrom<&TaggedValue>>::try_from(v).ok()).cloned();
|
||||||
@@ -2367,7 +2345,7 @@ pub mod choice {
|
|||||||
widgets.extend_from_slice(&[Separator::new(SeparatorStyle::Unrelated).widget_instance(), widget]);
|
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() {
|
if let Some(desc) = self.widget_factory.description() {
|
||||||
row = row.with_tooltip_description(desc);
|
row = row.with_tooltip_description(desc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use glam::IVec2;
|
|
||||||
use graph_craft::document::NodeId;
|
use graph_craft::document::NodeId;
|
||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
use graphene_std::Type;
|
use graphene_std::Type;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum FrontendGraphDataType {
|
pub enum FrontendGraphDataType {
|
||||||
#[default]
|
#[default]
|
||||||
General,
|
General,
|
||||||
@@ -42,7 +42,8 @@ impl FrontendGraphDataType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct FrontendGraphInput {
|
pub struct FrontendGraphInput {
|
||||||
#[serde(rename = "dataType")]
|
#[serde(rename = "dataType")]
|
||||||
pub data_type: FrontendGraphDataType,
|
pub data_type: FrontendGraphDataType,
|
||||||
@@ -57,21 +58,23 @@ pub struct FrontendGraphInput {
|
|||||||
pub connected_to: String,
|
pub connected_to: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct FrontendGraphOutput {
|
pub struct FrontendGraphOutput {
|
||||||
#[serde(rename = "dataType")]
|
#[serde(rename = "dataType")]
|
||||||
pub data_type: FrontendGraphDataType,
|
pub data_type: FrontendGraphDataType,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub description: String,
|
||||||
#[serde(rename = "resolvedType")]
|
#[serde(rename = "resolvedType")]
|
||||||
pub resolved_type: String,
|
pub resolved_type: String,
|
||||||
pub description: String,
|
|
||||||
/// If connected to an export, it is "export index {index}".
|
/// If connected to an export, it is "export index {index}".
|
||||||
/// If connected to a node, it is "{node name} input {input_index}".
|
/// If connected to a node, it is "{node name} input {input_index}".
|
||||||
#[serde(rename = "connectedTo")]
|
#[serde(rename = "connectedTo")]
|
||||||
pub connected_to: Vec<String>,
|
pub connected_to: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct FrontendNode {
|
pub struct FrontendNode {
|
||||||
pub id: graph_craft::document::NodeId,
|
pub id: graph_craft::document::NodeId,
|
||||||
#[serde(rename = "isLayer")]
|
#[serde(rename = "isLayer")]
|
||||||
@@ -95,13 +98,14 @@ pub struct FrontendNode {
|
|||||||
pub primary_input_connected_to_layer: bool,
|
pub primary_input_connected_to_layer: bool,
|
||||||
#[serde(rename = "primaryOutputConnectedToLayer")]
|
#[serde(rename = "primaryOutputConnectedToLayer")]
|
||||||
pub primary_output_connected_to_layer: bool,
|
pub primary_output_connected_to_layer: bool,
|
||||||
pub position: IVec2,
|
pub position: (i32, i32),
|
||||||
pub previewed: bool,
|
pub previewed: bool,
|
||||||
pub visible: bool,
|
pub visible: bool,
|
||||||
pub locked: bool,
|
pub locked: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct FrontendNodeType {
|
pub struct FrontendNodeType {
|
||||||
pub identifier: String,
|
pub identifier: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@@ -110,7 +114,8 @@ pub struct FrontendNodeType {
|
|||||||
pub input_types: Vec<String>,
|
pub input_types: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct DragStart {
|
pub struct DragStart {
|
||||||
pub start_x: f64,
|
pub start_x: f64,
|
||||||
pub start_y: f64,
|
pub start_y: f64,
|
||||||
@@ -118,14 +123,8 @@ pub struct DragStart {
|
|||||||
pub round_y: i32,
|
pub round_y: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
pub struct Transform {
|
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub scale: f64,
|
|
||||||
pub x: f64,
|
|
||||||
pub y: f64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
|
||||||
pub struct BoxSelection {
|
pub struct BoxSelection {
|
||||||
#[serde(rename = "startX")]
|
#[serde(rename = "startX")]
|
||||||
pub start_x: u32,
|
pub start_x: u32,
|
||||||
@@ -137,7 +136,8 @@ pub struct BoxSelection {
|
|||||||
pub end_y: u32,
|
pub end_y: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
#[serde(tag = "type", content = "data")]
|
#[serde(tag = "type", content = "data")]
|
||||||
pub enum ContextMenuData {
|
pub enum ContextMenuData {
|
||||||
ModifyNode {
|
ModifyNode {
|
||||||
@@ -158,22 +158,25 @@ pub enum ContextMenuData {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct ContextMenuInformation {
|
pub struct ContextMenuInformation {
|
||||||
// Stores whether the context menu is open and its position in graph coordinates
|
// Stores whether the context menu is open and its position in graph coordinates
|
||||||
#[serde(rename = "contextMenuCoordinates")]
|
#[serde(rename = "contextMenuCoordinates")]
|
||||||
pub context_menu_coordinates: IVec2,
|
pub context_menu_coordinates: (i32, i32),
|
||||||
#[serde(rename = "contextMenuData")]
|
#[serde(rename = "contextMenuData")]
|
||||||
pub context_menu_data: ContextMenuData,
|
pub context_menu_data: ContextMenuData,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct NodeGraphErrorDiagnostic {
|
pub struct NodeGraphErrorDiagnostic {
|
||||||
pub position: IVec2,
|
pub position: (i32, i32),
|
||||||
pub error: String,
|
pub error: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct FrontendClickTargets {
|
pub struct FrontendClickTargets {
|
||||||
#[serde(rename = "nodeClickTargets")]
|
#[serde(rename = "nodeClickTargets")]
|
||||||
pub node_click_targets: Vec<String>,
|
pub node_click_targets: Vec<String>,
|
||||||
@@ -189,7 +192,8 @@ pub struct FrontendClickTargets {
|
|||||||
pub modify_import_export: Vec<String>,
|
pub modify_import_export: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum Direction {
|
pub enum Direction {
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
|
|||||||
@@ -228,42 +228,38 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
widgets.push(LayoutGroup::Row {
|
widgets.push(LayoutGroup::row(vec![TextLabel::new("Grid").bold(true).widget_instance()]));
|
||||||
widgets: vec![TextLabel::new("Grid").bold(true).widget_instance()],
|
|
||||||
});
|
|
||||||
|
|
||||||
widgets.push(LayoutGroup::Row {
|
widgets.push(LayoutGroup::row(vec![
|
||||||
widgets: vec![
|
TextLabel::new("Type").table_align(true).widget_instance(),
|
||||||
TextLabel::new("Type").table_align(true).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
RadioInput::new(vec![
|
||||||
RadioInput::new(vec![
|
RadioEntryData::new("rectangular").label("Rectangular").on_update(update_val(grid, |grid, _| {
|
||||||
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 {
|
||||||
if let GridType::Isometric { y_axis_spacing, angle_a, angle_b } = grid.grid_type {
|
grid.isometric_y_spacing = y_axis_spacing;
|
||||||
grid.isometric_y_spacing = y_axis_spacing;
|
grid.isometric_angle_a = angle_a;
|
||||||
grid.isometric_angle_a = angle_a;
|
grid.isometric_angle_b = angle_b;
|
||||||
grid.isometric_angle_b = angle_b;
|
}
|
||||||
}
|
grid.grid_type = GridType::Rectangular { spacing: grid.rectangular_spacing };
|
||||||
grid.grid_type = GridType::Rectangular { spacing: grid.rectangular_spacing };
|
})),
|
||||||
})),
|
RadioEntryData::new("isometric").label("Isometric").on_update(update_val(grid, |grid, _| {
|
||||||
RadioEntryData::new("isometric").label("Isometric").on_update(update_val(grid, |grid, _| {
|
if let GridType::Rectangular { spacing } = grid.grid_type {
|
||||||
if let GridType::Rectangular { spacing } = grid.grid_type {
|
grid.rectangular_spacing = spacing;
|
||||||
grid.rectangular_spacing = spacing;
|
}
|
||||||
}
|
grid.grid_type = GridType::Isometric {
|
||||||
grid.grid_type = GridType::Isometric {
|
y_axis_spacing: grid.isometric_y_spacing,
|
||||||
y_axis_spacing: grid.isometric_y_spacing,
|
angle_a: grid.isometric_angle_a,
|
||||||
angle_a: grid.isometric_angle_a,
|
angle_b: grid.isometric_angle_b,
|
||||||
angle_b: grid.isometric_angle_b,
|
};
|
||||||
};
|
})),
|
||||||
})),
|
])
|
||||||
])
|
.min_width(200)
|
||||||
.min_width(200)
|
.selected_index(Some(match grid.grid_type {
|
||||||
.selected_index(Some(match grid.grid_type {
|
GridType::Rectangular { .. } => 0,
|
||||||
GridType::Rectangular { .. } => 0,
|
GridType::Isometric { .. } => 1,
|
||||||
GridType::Isometric { .. } => 1,
|
}))
|
||||||
}))
|
.widget_instance(),
|
||||||
.widget_instance(),
|
]));
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut color_widgets = vec![
|
let mut color_widgets = vec![
|
||||||
TextLabel::new("Display").table_align(true).widget_instance(),
|
TextLabel::new("Display").table_align(true).widget_instance(),
|
||||||
@@ -288,80 +284,72 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
|||||||
}))
|
}))
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
);
|
);
|
||||||
widgets.push(LayoutGroup::Row { widgets: color_widgets });
|
widgets.push(LayoutGroup::row(color_widgets));
|
||||||
|
|
||||||
widgets.push(LayoutGroup::Row {
|
widgets.push(LayoutGroup::row(vec![
|
||||||
widgets: vec![
|
TextLabel::new("Origin").table_align(true).widget_instance(),
|
||||||
TextLabel::new("Origin").table_align(true).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
NumberInput::new(Some(grid.origin.x))
|
||||||
NumberInput::new(Some(grid.origin.x))
|
.label("X")
|
||||||
.label("X")
|
.unit(" px")
|
||||||
.unit(" px")
|
.min_width(98)
|
||||||
.min_width(98)
|
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.x)))
|
||||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.x)))
|
.widget_instance(),
|
||||||
.widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
NumberInput::new(Some(grid.origin.y))
|
||||||
NumberInput::new(Some(grid.origin.y))
|
.label("Y")
|
||||||
.label("Y")
|
.unit(" px")
|
||||||
.unit(" px")
|
.min_width(98)
|
||||||
.min_width(98)
|
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.y)))
|
||||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.y)))
|
.widget_instance(),
|
||||||
.widget_instance(),
|
]));
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
match grid.grid_type {
|
match grid.grid_type {
|
||||||
GridType::Rectangular { spacing } => widgets.push(LayoutGroup::Row {
|
GridType::Rectangular { spacing } => widgets.push(LayoutGroup::row(vec![
|
||||||
widgets: vec![
|
TextLabel::new("Spacing").table_align(true).widget_instance(),
|
||||||
TextLabel::new("Spacing").table_align(true).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
|
NumberInput::new(Some(spacing.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)))
|
||||||
|
.widget_instance(),
|
||||||
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
|
NumberInput::new(Some(spacing.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)))
|
||||||
|
.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(),
|
||||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||||
NumberInput::new(Some(spacing.x))
|
NumberInput::new(Some(y_axis_spacing))
|
||||||
.label("X")
|
|
||||||
.unit(" px")
|
.unit(" px")
|
||||||
.min(0.)
|
.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)
|
.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| grid.grid_type.angle_a()))
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||||
NumberInput::new(Some(spacing.y))
|
NumberInput::new(Some(angle_b))
|
||||||
.label("Y")
|
.unit("°")
|
||||||
.unit(" px")
|
|
||||||
.min(0.)
|
|
||||||
.min_width(98)
|
.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| grid.grid_type.angle_b()))
|
||||||
.widget_instance(),
|
.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(),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ pub enum GizmoEmphasis {
|
|||||||
|
|
||||||
// TODO Remove duplicated definition of this in `utility_types_web.rs`
|
// 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.
|
/// Types of overlays used by DocumentMessage to enable/disable the selected set of viewport overlays.
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum OverlaysType {
|
pub enum OverlaysType {
|
||||||
ArtboardName,
|
ArtboardName,
|
||||||
CompassRose,
|
CompassRose,
|
||||||
@@ -60,7 +61,8 @@ pub enum OverlaysType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO Remove duplicated definition of this in `utility_types_web.rs`
|
// TODO Remove duplicated definition of this in `utility_types_web.rs`
|
||||||
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct OverlaysVisibilitySettings {
|
pub struct OverlaysVisibilitySettings {
|
||||||
pub all: bool,
|
pub all: bool,
|
||||||
@@ -160,11 +162,11 @@ impl OverlaysVisibilitySettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(serde::Serialize, serde::Deserialize)]
|
||||||
pub struct OverlayContext {
|
pub struct OverlayContext {
|
||||||
// Serde functionality isn't used but is required by the message system macros
|
// Serde functionality isn't used but is required by the message system macros
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
#[specta(skip)]
|
|
||||||
internal: Arc<Mutex<OverlayContextInternal>>,
|
internal: Arc<Mutex<OverlayContextInternal>>,
|
||||||
pub viewport: ViewportMessageHandler,
|
pub viewport: ViewportMessageHandler,
|
||||||
pub visibility_settings: OverlaysVisibilitySettings,
|
pub visibility_settings: OverlaysVisibilitySettings,
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ pub enum GizmoEmphasis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Types of overlays used by DocumentMessage to enable/disable the selected set of viewport overlays.
|
/// Types of overlays used by DocumentMessage to enable/disable the selected set of viewport overlays.
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum OverlaysType {
|
pub enum OverlaysType {
|
||||||
ArtboardName,
|
ArtboardName,
|
||||||
CompassRose,
|
CompassRose,
|
||||||
@@ -52,7 +53,8 @@ pub enum OverlaysType {
|
|||||||
Handles,
|
Handles,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct OverlaysVisibilitySettings {
|
pub struct OverlaysVisibilitySettings {
|
||||||
pub all: bool,
|
pub all: bool,
|
||||||
@@ -150,11 +152,11 @@ impl OverlaysVisibilitySettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct OverlayContext {
|
pub struct OverlayContext {
|
||||||
// Serde functionality isn't used but is required by the message system macros
|
// Serde functionality isn't used but is required by the message system macros
|
||||||
#[serde(skip, default = "overlay_canvas_context")]
|
#[serde(skip, default = "overlay_canvas_context")]
|
||||||
#[specta(skip)]
|
|
||||||
pub render_context: web_sys::CanvasRenderingContext2d,
|
pub render_context: web_sys::CanvasRenderingContext2d,
|
||||||
pub viewport: ViewportMessageHandler,
|
pub viewport: ViewportMessageHandler,
|
||||||
pub visibility_settings: OverlaysVisibilitySettings,
|
pub visibility_settings: OverlaysVisibilitySettings,
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ use super::network_interface::NodeTemplate;
|
|||||||
use graph_craft::document::NodeId;
|
use graph_craft::document::NodeId;
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, Eq, Debug, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub enum Clipboard {
|
pub enum Clipboard {
|
||||||
Internal,
|
Internal,
|
||||||
Device,
|
Device,
|
||||||
|
|||||||
@@ -234,7 +234,8 @@ impl DocumentMetadata {
|
|||||||
// ===================
|
// ===================
|
||||||
|
|
||||||
/// ID of a layer node
|
/// ID of a layer node
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct LayerNodeIdentifier(NonZeroU64);
|
pub struct LayerNodeIdentifier(NonZeroU64);
|
||||||
|
|
||||||
impl core::fmt::Debug for LayerNodeIdentifier {
|
impl core::fmt::Debug for LayerNodeIdentifier {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ use glam::DVec2;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[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)]
|
||||||
pub struct DocumentId(pub u64);
|
pub struct DocumentId(pub u64);
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash)]
|
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash)]
|
||||||
@@ -12,13 +13,15 @@ pub enum FlipAxis {
|
|||||||
Y,
|
Y,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash)]
|
||||||
pub enum AlignAxis {
|
pub enum AlignAxis {
|
||||||
X,
|
X,
|
||||||
Y,
|
Y,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Hash)]
|
||||||
pub enum AlignAggregate {
|
pub enum AlignAggregate {
|
||||||
Min,
|
Min,
|
||||||
Max,
|
Max,
|
||||||
@@ -707,5 +710,5 @@ impl PTZ {
|
|||||||
#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum GroupFolderType {
|
pub enum GroupFolderType {
|
||||||
Layer,
|
Layer,
|
||||||
BooleanOperation(graphene_std::path_bool::BooleanOperation),
|
BooleanOperation(graphene_std::vector::misc::BooleanOperation),
|
||||||
}
|
}
|
||||||
@@ -5723,14 +5723,16 @@ impl Iterator for FlowIter<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ImportOrExport {
|
pub enum ImportOrExport {
|
||||||
Import(usize),
|
Import(usize),
|
||||||
Export(usize),
|
Export(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents an input connector with index based on the [`DocumentNode::inputs`] index, not the visible input index
|
/// Represents an input connector with index based on the [`DocumentNode::inputs`] index, not the visible input index
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum InputConnector {
|
pub enum InputConnector {
|
||||||
#[serde(rename = "node")]
|
#[serde(rename = "node")]
|
||||||
Node {
|
Node {
|
||||||
@@ -5770,7 +5772,8 @@ impl InputConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Represents an output connector
|
/// Represents an output connector
|
||||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum OutputConnector {
|
pub enum OutputConnector {
|
||||||
#[serde(rename = "node")]
|
#[serde(rename = "node")]
|
||||||
Node {
|
Node {
|
||||||
|
|||||||
@@ -1,25 +1,28 @@
|
|||||||
use super::document_metadata::{DocumentMetadata, LayerNodeIdentifier};
|
use super::document_metadata::{DocumentMetadata, LayerNodeIdentifier};
|
||||||
use super::network_interface::NodeNetworkInterface;
|
use super::network_interface::NodeNetworkInterface;
|
||||||
|
use crate::messages::frontend::IconName;
|
||||||
use crate::messages::tool::common_functionality::graph_modification_utils;
|
use crate::messages::tool::common_functionality::graph_modification_utils;
|
||||||
use glam::DVec2;
|
use glam::DVec2;
|
||||||
use graph_craft::document::{NodeId, NodeNetwork};
|
use graph_craft::document::{NodeId, NodeNetwork};
|
||||||
|
|
||||||
/// Represents an entry in the layer tree hierarchy, sent to the frontend.
|
/// 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.
|
/// Each entry contains its layer ID and a list of its visible children.
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||||
pub struct LayerStructureEntry {
|
pub struct LayerStructureEntry {
|
||||||
#[serde(rename = "layerId")]
|
#[serde(rename = "layerId")]
|
||||||
pub layer_id: NodeId,
|
pub layer_id: NodeId,
|
||||||
pub children: Vec<LayerStructureEntry>,
|
pub children: Vec<LayerStructureEntry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||||
pub struct LayerPanelEntry {
|
pub struct LayerPanelEntry {
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
#[serde(rename = "implementationName")]
|
#[serde(rename = "implementationName")]
|
||||||
pub implementation_name: String,
|
pub implementation_name: String,
|
||||||
#[serde(rename = "iconName")]
|
#[serde(rename = "iconName")]
|
||||||
pub icon_name: Option<String>,
|
pub icon_name: Option<IconName>,
|
||||||
pub alias: String,
|
pub alias: String,
|
||||||
#[serde(rename = "inSelectedNetwork")]
|
#[serde(rename = "inSelectedNetwork")]
|
||||||
pub in_selected_network: bool,
|
pub in_selected_network: bool,
|
||||||
@@ -47,7 +50,8 @@ pub struct LayerPanelEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// IMPORTANT: the same node may appear multiple times.
|
/// IMPORTANT: the same node may appear multiple times.
|
||||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, Eq, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||||
pub struct SelectedNodes(pub Vec<NodeId>);
|
pub struct SelectedNodes(pub Vec<NodeId>);
|
||||||
|
|
||||||
impl SelectedNodes {
|
impl SelectedNodes {
|
||||||
@@ -157,5 +161,6 @@ impl SelectedNodes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, Eq, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||||
pub struct CollapsedLayers(pub Vec<LayerNodeIdentifier>);
|
pub struct CollapsedLayers(pub Vec<LayerNodeIdentifier>);
|
||||||
@@ -3,7 +3,8 @@ use glam::{DVec2, IVec2};
|
|||||||
use graphene_std::{uuid::NodeId, vector::misc::dvec2_to_point};
|
use graphene_std::{uuid::NodeId, vector::misc::dvec2_to_point};
|
||||||
use kurbo::{BezPath, DEFAULT_ACCURACY, Line, Point, Shape};
|
use kurbo::{BezPath, DEFAULT_ACCURACY, Line, Point, Shape};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct WirePath {
|
pub struct WirePath {
|
||||||
#[serde(rename = "pathString")]
|
#[serde(rename = "pathString")]
|
||||||
pub path_string: String,
|
pub path_string: String,
|
||||||
@@ -13,7 +14,8 @@ pub struct WirePath {
|
|||||||
pub dashed: bool,
|
pub dashed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct WirePathUpdate {
|
pub struct WirePathUpdate {
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
#[serde(rename = "inputIndex")]
|
#[serde(rename = "inputIndex")]
|
||||||
@@ -23,7 +25,8 @@ pub struct WirePathUpdate {
|
|||||||
pub wire_path_update: Option<WirePath>,
|
pub wire_path_update: Option<WirePath>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum GraphWireStyle {
|
pub enum GraphWireStyle {
|
||||||
#[default]
|
#[default]
|
||||||
Direct = 0,
|
Direct = 0,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const TEXT_REPLACEMENTS: &[(&str, &str)] = &[
|
|||||||
),
|
),
|
||||||
("graphene_core::transform::Footprint", "graphene_core::transform::Footprint"),
|
("graphene_core::transform::Footprint", "graphene_core::transform::Footprint"),
|
||||||
("\"OptionalF64\":", "\"F64\":"),
|
("\"OptionalF64\":", "\"F64\":"),
|
||||||
|
("\"path_bool_nodes::BooleanOperation\"", "\"vector_types::vector::misc::BooleanOperation\""),
|
||||||
];
|
];
|
||||||
|
|
||||||
pub struct NodeReplacement<'a> {
|
pub struct NodeReplacement<'a> {
|
||||||
@@ -454,10 +455,10 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
// ================================
|
// ================================
|
||||||
// path-bool
|
// path bool
|
||||||
// ================================
|
// ================================
|
||||||
NodeReplacement {
|
NodeReplacement {
|
||||||
node: graphene_std::path_bool::boolean_operation::IDENTIFIER,
|
node: graphene_std::path_bool_nodes::boolean_operation::IDENTIFIER,
|
||||||
aliases: &["graphene_path_bool::BooleanOperationNode", "graphene_std::vector::BooleanOperationNode"],
|
aliases: &["graphene_path_bool::BooleanOperationNode", "graphene_std::vector::BooleanOperationNode"],
|
||||||
},
|
},
|
||||||
// ================================
|
// ================================
|
||||||
@@ -1708,6 +1709,132 @@ 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);
|
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)
|
// Add context features to nodes that don't have them (fine-grained context caching migration)
|
||||||
if node.context_features == graphene_std::ContextDependencies::default()
|
if node.context_features == graphene_std::ContextDependencies::default()
|
||||||
&& let Some(reference) = document.network_interface.reference(node_id, network_path).clone()
|
&& let Some(reference) = document.network_interface.reference(node_id, network_path).clone()
|
||||||
|
|||||||
@@ -1011,12 +1011,11 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||||||
PortfolioMessage::RequestWelcomeScreenButtonsLayout => {
|
PortfolioMessage::RequestWelcomeScreenButtonsLayout => {
|
||||||
let donate = "https://graphite.art/donate/";
|
let donate = "https://graphite.art/donate/";
|
||||||
|
|
||||||
let table = LayoutGroup::Table {
|
let table = LayoutGroup::table(
|
||||||
unstyled: true,
|
vec![
|
||||||
rows: vec![
|
|
||||||
vec![
|
vec![
|
||||||
TextButton::new("New Document")
|
TextButton::new("New Document")
|
||||||
.icon(Some("File".into()))
|
.icon("File")
|
||||||
.flush(true)
|
.flush(true)
|
||||||
.on_commit(|_| DialogMessage::RequestNewDocumentDialog.into())
|
.on_commit(|_| DialogMessage::RequestNewDocumentDialog.into())
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
@@ -1024,7 +1023,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
TextButton::new("Open Document")
|
TextButton::new("Open Document")
|
||||||
.icon(Some("Folder".into()))
|
.icon("Folder")
|
||||||
.flush(true)
|
.flush(true)
|
||||||
.on_commit(|_| PortfolioMessage::Open.into())
|
.on_commit(|_| PortfolioMessage::Open.into())
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
@@ -1032,20 +1031,21 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
TextButton::new("Open Demo Artwork")
|
TextButton::new("Open Demo Artwork")
|
||||||
.icon(Some("Image".into()))
|
.icon("Image")
|
||||||
.flush(true)
|
.flush(true)
|
||||||
.on_commit(|_| DialogMessage::RequestDemoArtworkDialog.into())
|
.on_commit(|_| DialogMessage::RequestDemoArtworkDialog.into())
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
TextButton::new("Support the Development Fund")
|
TextButton::new("Support the Development Fund")
|
||||||
.icon(Some("Heart".into()))
|
.icon("Heart")
|
||||||
.flush(true)
|
.flush(true)
|
||||||
.on_commit(move |_| FrontendMessage::TriggerVisitLink { url: donate.to_string() }.into())
|
.on_commit(move |_| FrontendMessage::TriggerVisitLink { url: donate.to_string() }.into())
|
||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
};
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
responses.add(LayoutMessage::DestroyLayout {
|
responses.add(LayoutMessage::DestroyLayout {
|
||||||
layout_target: LayoutTarget::WelcomeScreenButtons,
|
layout_target: LayoutTarget::WelcomeScreenButtons,
|
||||||
@@ -1057,11 +1057,11 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||||||
}
|
}
|
||||||
PortfolioMessage::RequestStatusBarInfoLayout => {
|
PortfolioMessage::RequestStatusBarInfoLayout => {
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
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"
|
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"
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
let widgets = vec![];
|
let widgets = vec![];
|
||||||
|
|
||||||
let row = LayoutGroup::Row { widgets };
|
let row = LayoutGroup::row(widgets);
|
||||||
|
|
||||||
responses.add(LayoutMessage::SendLayout {
|
responses.add(LayoutMessage::SendLayout {
|
||||||
layout: Layout(vec![row]),
|
layout: Layout(vec![row]),
|
||||||
@@ -1191,7 +1191,6 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||||||
Ok(message) => responses.add_front(message),
|
Ok(message) => responses.add_front(message),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(target_family = "wasm"))]
|
|
||||||
PortfolioMessage::SubmitEyedropperPreviewRender => {
|
PortfolioMessage::SubmitEyedropperPreviewRender => {
|
||||||
use crate::consts::EYEDROPPER_PREVIEW_AREA_RESOLUTION;
|
use crate::consts::EYEDROPPER_PREVIEW_AREA_RESOLUTION;
|
||||||
|
|
||||||
@@ -1223,10 +1222,6 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
|||||||
Ok(message) => responses.add_front(message),
|
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 => {
|
PortfolioMessage::ToggleFocusDocument => {
|
||||||
self.focus_document = !self.focus_document;
|
self.focus_document = !self.focus_document;
|
||||||
responses.add(MenuBarMessage::SendLayout);
|
responses.add(MenuBarMessage::SendLayout);
|
||||||
|
|||||||
@@ -6,16 +6,38 @@ use crate::messages::prelude::*;
|
|||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum PreferencesMessage {
|
pub enum PreferencesMessage {
|
||||||
// Management messages
|
// Management messages
|
||||||
Load { preferences: PreferencesMessageHandler },
|
Load {
|
||||||
|
preferences: PreferencesMessageHandler,
|
||||||
|
},
|
||||||
ResetToDefaults,
|
ResetToDefaults,
|
||||||
|
|
||||||
// Per-preference messages
|
// Per-preference messages
|
||||||
SelectionMode { selection_mode: SelectionMode },
|
SelectionMode {
|
||||||
BrushTool { enabled: bool },
|
selection_mode: SelectionMode,
|
||||||
ModifyLayout { zoom_with_scroll: bool },
|
},
|
||||||
GraphWireStyle { style: GraphWireStyle },
|
BrushTool {
|
||||||
ViewportZoomWheelRate { rate: f64 },
|
enabled: bool,
|
||||||
UIScale { scale: f64 },
|
},
|
||||||
DisableUIAcceleration { disable_ui_acceleration: bool },
|
ModifyLayout {
|
||||||
MaxRenderRegionSize { size: u32 },
|
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,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,8 @@ pub struct PreferencesMessageContext<'a> {
|
|||||||
pub tool_message_handler: &'a ToolMessageHandler,
|
pub tool_message_handler: &'a ToolMessageHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, specta::Type, ExtractField)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, ExtractField)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct PreferencesMessageHandler {
|
pub struct PreferencesMessageHandler {
|
||||||
pub selection_mode: SelectionMode,
|
pub selection_mode: SelectionMode,
|
||||||
@@ -20,15 +21,23 @@ pub struct PreferencesMessageHandler {
|
|||||||
pub graph_wire_style: GraphWireStyle,
|
pub graph_wire_style: GraphWireStyle,
|
||||||
pub viewport_zoom_wheel_rate: f64,
|
pub viewport_zoom_wheel_rate: f64,
|
||||||
pub ui_scale: f64,
|
pub ui_scale: f64,
|
||||||
pub disable_ui_acceleration: bool,
|
|
||||||
pub max_render_region_size: u32,
|
pub max_render_region_size: u32,
|
||||||
|
pub disable_ui_acceleration: bool,
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub vsync: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PreferencesMessageHandler {
|
impl PreferencesMessageHandler {
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
pub fn needs_restart(&self, other: &Self) -> bool {
|
pub fn needs_restart(&self, other: &Self) -> bool {
|
||||||
self.disable_ui_acceleration != other.disable_ui_acceleration
|
self.disable_ui_acceleration != other.disable_ui_acceleration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub fn needs_restart(&self, other: &Self) -> bool {
|
||||||
|
self.disable_ui_acceleration != other.disable_ui_acceleration || self.vsync != other.vsync
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_selection_mode(&self) -> SelectionMode {
|
pub fn get_selection_mode(&self) -> SelectionMode {
|
||||||
self.selection_mode
|
self.selection_mode
|
||||||
}
|
}
|
||||||
@@ -53,8 +62,10 @@ impl Default for PreferencesMessageHandler {
|
|||||||
graph_wire_style: GraphWireStyle::default(),
|
graph_wire_style: GraphWireStyle::default(),
|
||||||
viewport_zoom_wheel_rate: VIEWPORT_ZOOM_WHEEL_RATE,
|
viewport_zoom_wheel_rate: VIEWPORT_ZOOM_WHEEL_RATE,
|
||||||
ui_scale: UI_SCALE_DEFAULT,
|
ui_scale: UI_SCALE_DEFAULT,
|
||||||
disable_ui_acceleration: false,
|
|
||||||
max_render_region_size: EditorPreferences::default().max_render_region_size,
|
max_render_region_size: EditorPreferences::default().max_render_region_size,
|
||||||
|
disable_ui_acceleration: false,
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
vsync: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,14 +122,18 @@ impl MessageHandler<PreferencesMessage, PreferencesMessageContext<'_>> for Prefe
|
|||||||
self.ui_scale = scale;
|
self.ui_scale = scale;
|
||||||
responses.add(FrontendMessage::UpdateUIScale { scale: self.ui_scale });
|
responses.add(FrontendMessage::UpdateUIScale { scale: self.ui_scale });
|
||||||
}
|
}
|
||||||
PreferencesMessage::DisableUIAcceleration { disable_ui_acceleration } => {
|
|
||||||
self.disable_ui_acceleration = disable_ui_acceleration;
|
|
||||||
}
|
|
||||||
PreferencesMessage::MaxRenderRegionSize { size } => {
|
PreferencesMessage::MaxRenderRegionSize { size } => {
|
||||||
self.max_render_region_size = size;
|
self.max_render_region_size = size;
|
||||||
responses.add(PortfolioMessage::EditorPreferences);
|
responses.add(PortfolioMessage::EditorPreferences);
|
||||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
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() });
|
responses.add(FrontendMessage::TriggerSavePreferences { preferences: self.clone() });
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type, Hash)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, Hash)]
|
||||||
pub enum SelectionMode {
|
pub enum SelectionMode {
|
||||||
#[default]
|
#[default]
|
||||||
Touched = 0,
|
Touched = 0,
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ use crate::messages::prelude::*;
|
|||||||
use graphene_std::Color;
|
use graphene_std::Color;
|
||||||
use graphene_std::vector::style::FillChoice;
|
use graphene_std::vector::style::FillChoice;
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ToolColorType {
|
pub enum ToolColorType {
|
||||||
Primary,
|
Primary,
|
||||||
Secondary,
|
Secondary,
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ pub fn get_origin(layer: LayerNodeIdentifier, network_interface: &NodeNetworkInt
|
|||||||
|
|
||||||
pub fn get_viewport_origin(layer: LayerNodeIdentifier, network_interface: &NodeNetworkInterface) -> DVec2 {
|
pub fn get_viewport_origin(layer: LayerNodeIdentifier, network_interface: &NodeNetworkInterface) -> DVec2 {
|
||||||
let origin = get_origin(layer, network_interface).unwrap_or_default();
|
let origin = get_origin(layer, network_interface).unwrap_or_default();
|
||||||
network_interface.document_metadata().document_to_viewport.transform_point2(origin)
|
network_interface.document_metadata().downstream_transform_to_viewport(layer).transform_point2(origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_viewport_center(layer: LayerNodeIdentifier, network_interface: &NodeNetworkInterface) -> DVec2 {
|
pub fn get_viewport_center(layer: LayerNodeIdentifier, network_interface: &NodeNetworkInterface) -> DVec2 {
|
||||||
|
|||||||
@@ -150,7 +150,8 @@ impl PivotGizmo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum PivotGizmoType {
|
pub enum PivotGizmoType {
|
||||||
// Pivot
|
// Pivot
|
||||||
#[default]
|
#[default]
|
||||||
@@ -161,7 +162,8 @@ pub enum PivotGizmoType {
|
|||||||
// TODO: Add "Individual"
|
// TODO: Add "Individual"
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Default, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Copy, Default, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct PivotGizmoState {
|
pub struct PivotGizmoState {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub gizmo_type: PivotGizmoType,
|
pub gizmo_type: PivotGizmoType,
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
|
use super::line_shape::{LineEnd, generate_line};
|
||||||
use super::shape_utility::ShapeToolModifierKey;
|
use super::shape_utility::ShapeToolModifierKey;
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_proto_node_type;
|
use crate::consts::BOUNDS_SELECT_THRESHOLD;
|
||||||
|
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
|
||||||
|
use crate::messages::portfolio::document::node_graph::document_node_definitions::{DefinitionIdentifier, resolve_document_node_type};
|
||||||
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
||||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||||
use crate::messages::portfolio::document::utility_types::network_interface::{InputConnector, NodeTemplate};
|
use crate::messages::portfolio::document::utility_types::network_interface::{InputConnector, NodeTemplate};
|
||||||
use crate::messages::prelude::*;
|
use crate::messages::prelude::*;
|
||||||
use crate::messages::tool::common_functionality::graph_modification_utils;
|
use crate::messages::tool::common_functionality::graph_modification_utils;
|
||||||
use glam::DVec2;
|
pub use crate::messages::tool::common_functionality::graph_modification_utils::NodeGraphLayer;
|
||||||
|
use crate::messages::tool::common_functionality::snapping::SnapData;
|
||||||
|
use glam::{DAffine2, DVec2};
|
||||||
use graph_craft::document::NodeInput;
|
use graph_craft::document::NodeInput;
|
||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
@@ -15,40 +20,43 @@ use std::collections::VecDeque;
|
|||||||
pub struct Arrow;
|
pub struct Arrow;
|
||||||
|
|
||||||
impl Arrow {
|
impl Arrow {
|
||||||
pub fn create_node(document: &DocumentMessageHandler, drag_start: DVec2, shaft_width: f64, head_width: f64, head_length: f64) -> NodeTemplate {
|
pub fn create_node(shaft_width: f64, head_width: f64, head_length: f64) -> NodeTemplate {
|
||||||
let node_type = resolve_proto_node_type(graphene_std::vector_nodes::arrow::IDENTIFIER).expect("Arrow node does not exist");
|
let identifier = DefinitionIdentifier::ProtoNode(graphene_std::vector_nodes::arrow::IDENTIFIER);
|
||||||
let viewport_pos = document.metadata().document_to_viewport.transform_point2(drag_start);
|
let node_type = resolve_document_node_type(&identifier).expect("Arrow node can't be found");
|
||||||
node_type.node_template_input_override([
|
node_type.node_template_input_override([
|
||||||
None,
|
None,
|
||||||
Some(NodeInput::value(TaggedValue::DVec2(viewport_pos), false)), // start
|
Some(NodeInput::value(TaggedValue::DVec2(DVec2::ZERO), false)), // arrow_to
|
||||||
Some(NodeInput::value(TaggedValue::DVec2(viewport_pos), false)), // end
|
Some(NodeInput::value(TaggedValue::F64(shaft_width), false)), // shaft_width
|
||||||
Some(NodeInput::value(TaggedValue::F64(shaft_width), false)), // shaft_width
|
Some(NodeInput::value(TaggedValue::F64(head_width), false)), // head_width
|
||||||
Some(NodeInput::value(TaggedValue::F64(head_width), false)), // head_width
|
Some(NodeInput::value(TaggedValue::F64(head_length), false)), // head_length
|
||||||
Some(NodeInput::value(TaggedValue::F64(head_length), false)), // head_length
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_shape(
|
pub fn update_shape(
|
||||||
document: &DocumentMessageHandler,
|
document: &DocumentMessageHandler,
|
||||||
input: &InputPreprocessorMessageHandler,
|
input: &InputPreprocessorMessageHandler,
|
||||||
_viewport: &ViewportMessageHandler,
|
viewport: &ViewportMessageHandler,
|
||||||
layer: LayerNodeIdentifier,
|
layer: LayerNodeIdentifier,
|
||||||
tool_data: &mut ShapeToolData,
|
tool_data: &mut ShapeToolData,
|
||||||
_modifier: ShapeToolModifierKey,
|
modifier: ShapeToolModifierKey,
|
||||||
responses: &mut VecDeque<Message>,
|
responses: &mut VecDeque<Message>,
|
||||||
) {
|
) {
|
||||||
// Track current mouse position in viewport space
|
let [center, snap_angle, lock_angle] = modifier;
|
||||||
|
|
||||||
tool_data.line_data.drag_current = input.mouse.position;
|
tool_data.line_data.drag_current = input.mouse.position;
|
||||||
|
|
||||||
// Convert both points to document space (matching Line tool pattern)
|
let keyboard = &input.keyboard;
|
||||||
let document_to_viewport = document.metadata().document_to_viewport;
|
let ignore = [layer];
|
||||||
let start_document = tool_data.data.drag_start;
|
let snap_data = SnapData::ignore(document, input, viewport, &ignore);
|
||||||
let end_document = document_to_viewport.inverse().transform_point2(tool_data.line_data.drag_current);
|
let mut document_points = generate_line(tool_data, snap_data, keyboard.key(lock_angle), keyboard.key(snap_angle), keyboard.key(center));
|
||||||
|
|
||||||
// Calculate length in document space for validation
|
if tool_data.line_data.dragging_endpoint == Some(LineEnd::Start) {
|
||||||
let delta = end_document - start_document;
|
document_points.swap(0, 1);
|
||||||
let length_document = delta.length();
|
}
|
||||||
if length_document < 1e-6 {
|
|
||||||
|
let arrow_to = document_points[1] - document_points[0];
|
||||||
|
|
||||||
|
if arrow_to.length() < 1e-6 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,18 +64,53 @@ impl Arrow {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update Arrow node start and end points with document space coordinates
|
let document_to_viewport = document.metadata().document_to_viewport;
|
||||||
|
|
||||||
responses.add(NodeGraphMessage::SetInput {
|
responses.add(NodeGraphMessage::SetInput {
|
||||||
input_connector: InputConnector::node(node_id, 1),
|
input_connector: InputConnector::node(node_id, 1),
|
||||||
input: NodeInput::value(TaggedValue::DVec2(start_document), false),
|
input: NodeInput::value(TaggedValue::DVec2(arrow_to), false),
|
||||||
});
|
});
|
||||||
responses.add(NodeGraphMessage::SetInput {
|
let downstream = document.metadata().downstream_transform_to_viewport(layer);
|
||||||
input_connector: InputConnector::node(node_id, 2),
|
let scope = downstream.inverse() * document_to_viewport;
|
||||||
input: NodeInput::value(TaggedValue::DVec2(end_document), false),
|
responses.add(GraphOperationMessage::TransformSet {
|
||||||
|
layer,
|
||||||
|
transform: DAffine2::from_translation(document_points[0]),
|
||||||
|
transform_in: TransformIn::Scope { scope },
|
||||||
|
skip_rerender: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn overlays(_document: &DocumentMessageHandler, _tool_data: &ShapeToolData, _overlay_context: &mut OverlayContext) {}
|
pub fn overlays(document: &DocumentMessageHandler, shape_tool_data: &mut ShapeToolData, mouse_position: DVec2, overlay_context: &mut OverlayContext) {
|
||||||
|
let arrow_layers: HashMap<LayerNodeIdentifier, [DVec2; 2]> = document
|
||||||
|
.network_interface
|
||||||
|
.selected_nodes()
|
||||||
|
.selected_visible_and_unlocked_layers(&document.network_interface)
|
||||||
|
.filter_map(|layer| {
|
||||||
|
let node_inputs = NodeGraphLayer::new(layer, &document.network_interface).find_node_inputs(&DefinitionIdentifier::ProtoNode(graphene_std::vector_nodes::arrow::IDENTIFIER))?;
|
||||||
|
let Some(&TaggedValue::DVec2(arrow_to)) = node_inputs[1].as_value() else { return None };
|
||||||
|
|
||||||
|
let transform = document.metadata().transform_to_viewport(layer);
|
||||||
|
let viewport_start = transform.transform_point2(DVec2::ZERO);
|
||||||
|
let viewport_end = transform.transform_point2(arrow_to);
|
||||||
|
|
||||||
|
if !arrow_to.abs_diff_eq(DVec2::ZERO, f64::EPSILON * 1000.) {
|
||||||
|
let is_editing = shape_tool_data.line_data.editing_layer == Some(layer);
|
||||||
|
for (i, pos) in [viewport_start, viewport_end].into_iter().enumerate() {
|
||||||
|
let is_dragged = is_editing && matches!((i, &shape_tool_data.line_data.dragging_endpoint), (0, Some(LineEnd::Start)) | (1, Some(LineEnd::End)));
|
||||||
|
if is_dragged || (pos - mouse_position).length_squared() < BOUNDS_SELECT_THRESHOLD.powi(2) {
|
||||||
|
overlay_context.hover_manipulator_anchor(pos, is_dragged);
|
||||||
|
} else {
|
||||||
|
overlay_context.square(pos, Some(6.), None, None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Some((layer, [DVec2::ZERO, arrow_to]))
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
shape_tool_data.line_data.selected_layers_with_position.extend(arrow_layers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
use super::shape_utility::ShapeToolModifierKey;
|
use super::shape_utility::ShapeToolModifierKey;
|
||||||
use crate::consts::{BOUNDS_SELECT_THRESHOLD, LINE_ROTATE_SNAP_ANGLE};
|
use crate::consts::{BOUNDS_SELECT_THRESHOLD, LINE_ROTATE_SNAP_ANGLE};
|
||||||
|
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
|
||||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::{DefinitionIdentifier, resolve_document_node_type};
|
use crate::messages::portfolio::document::node_graph::document_node_definitions::{DefinitionIdentifier, resolve_document_node_type};
|
||||||
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
||||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||||
@@ -9,7 +10,7 @@ pub use crate::messages::tool::common_functionality::graph_modification_utils::N
|
|||||||
use crate::messages::tool::common_functionality::snapping::{SnapCandidatePoint, SnapConstraint, SnapData, SnapTypeConfiguration};
|
use crate::messages::tool::common_functionality::snapping::{SnapCandidatePoint, SnapConstraint, SnapData, SnapTypeConfiguration};
|
||||||
use crate::messages::tool::tool_messages::shape_tool::ShapeToolData;
|
use crate::messages::tool::tool_messages::shape_tool::ShapeToolData;
|
||||||
use crate::messages::tool::tool_messages::tool_prelude::*;
|
use crate::messages::tool::tool_messages::tool_prelude::*;
|
||||||
use glam::DVec2;
|
use glam::{DAffine2, DVec2};
|
||||||
use graph_craft::document::NodeInput;
|
use graph_craft::document::NodeInput;
|
||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
@@ -36,14 +37,10 @@ pub struct LineToolData {
|
|||||||
pub struct Line;
|
pub struct Line;
|
||||||
|
|
||||||
impl Line {
|
impl Line {
|
||||||
pub fn create_node(document: &DocumentMessageHandler, drag_start: DVec2) -> NodeTemplate {
|
pub fn create_node() -> NodeTemplate {
|
||||||
let identifier = DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::line::IDENTIFIER);
|
let identifier = DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::line::IDENTIFIER);
|
||||||
let node_type = resolve_document_node_type(&identifier).expect("Line node can't be found");
|
let node_type = resolve_document_node_type(&identifier).expect("Line node can't be found");
|
||||||
node_type.node_template_input_override([
|
node_type.node_template_input_override([None, Some(NodeInput::value(TaggedValue::DVec2(DVec2::ZERO), false))])
|
||||||
None,
|
|
||||||
Some(NodeInput::value(TaggedValue::DVec2(document.metadata().document_to_viewport.transform_point2(drag_start)), false)),
|
|
||||||
Some(NodeInput::value(TaggedValue::DVec2(document.metadata().document_to_viewport.transform_point2(drag_start)), false)),
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_shape(
|
pub fn update_shape(
|
||||||
@@ -72,18 +69,25 @@ impl Line {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Compute line_to in document space
|
||||||
|
let line_to = document_points[1] - document_points[0];
|
||||||
|
|
||||||
responses.add(NodeGraphMessage::SetInput {
|
responses.add(NodeGraphMessage::SetInput {
|
||||||
input_connector: InputConnector::node(node_id, 1),
|
input_connector: InputConnector::node(node_id, 1),
|
||||||
input: NodeInput::value(TaggedValue::DVec2(document_points[0]), false),
|
input: NodeInput::value(TaggedValue::DVec2(line_to), false),
|
||||||
});
|
});
|
||||||
responses.add(NodeGraphMessage::SetInput {
|
let document_to_viewport = document.metadata().document_to_viewport;
|
||||||
input_connector: InputConnector::node(node_id, 2),
|
let downstream = document.metadata().downstream_transform_to_viewport(layer);
|
||||||
input: NodeInput::value(TaggedValue::DVec2(document_points[1]), false),
|
let scope = downstream.inverse() * document_to_viewport;
|
||||||
|
responses.add(GraphOperationMessage::TransformSet {
|
||||||
|
layer,
|
||||||
|
transform: DAffine2::from_translation(document_points[0]),
|
||||||
|
transform_in: TransformIn::Scope { scope },
|
||||||
|
skip_rerender: false,
|
||||||
});
|
});
|
||||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn overlays(document: &DocumentMessageHandler, shape_tool_data: &mut ShapeToolData, overlay_context: &mut OverlayContext) {
|
pub fn overlays(document: &DocumentMessageHandler, shape_tool_data: &mut ShapeToolData, mouse_position: DVec2, overlay_context: &mut OverlayContext) {
|
||||||
shape_tool_data.line_data.selected_layers_with_position = document
|
shape_tool_data.line_data.selected_layers_with_position = document
|
||||||
.network_interface
|
.network_interface
|
||||||
.selected_nodes()
|
.selected_nodes()
|
||||||
@@ -92,24 +96,35 @@ impl Line {
|
|||||||
let node_inputs =
|
let node_inputs =
|
||||||
NodeGraphLayer::new(layer, &document.network_interface).find_node_inputs(&DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::line::IDENTIFIER))?;
|
NodeGraphLayer::new(layer, &document.network_interface).find_node_inputs(&DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::line::IDENTIFIER))?;
|
||||||
|
|
||||||
let (Some(&TaggedValue::DVec2(start)), Some(&TaggedValue::DVec2(end))) = (node_inputs[1].as_value(), node_inputs[2].as_value()) else {
|
let Some(&TaggedValue::DVec2(line_to)) = node_inputs[1].as_value() else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
let [viewport_start, viewport_end] = [start, end].map(|point| document.metadata().transform_to_viewport(layer).transform_point2(point));
|
// Line goes from local origin (0,0) to line_to, positioned by the Transform node
|
||||||
if !start.abs_diff_eq(end, f64::EPSILON * 1000.) {
|
let transform = document.metadata().transform_to_viewport(layer);
|
||||||
|
let viewport_start = transform.transform_point2(DVec2::ZERO);
|
||||||
|
let viewport_end = transform.transform_point2(line_to);
|
||||||
|
if !line_to.abs_diff_eq(DVec2::ZERO, f64::EPSILON * 1000.) {
|
||||||
overlay_context.line(viewport_start, viewport_end, None, None);
|
overlay_context.line(viewport_start, viewport_end, None, None);
|
||||||
overlay_context.square(viewport_start, Some(6.), None, None);
|
let is_editing = shape_tool_data.line_data.editing_layer == Some(layer);
|
||||||
overlay_context.square(viewport_end, Some(6.), None, None);
|
for (i, pos) in [viewport_start, viewport_end].into_iter().enumerate() {
|
||||||
|
let is_dragged = is_editing && matches!((i, &shape_tool_data.line_data.dragging_endpoint), (0, Some(LineEnd::Start)) | (1, Some(LineEnd::End)));
|
||||||
|
if is_dragged || (pos - mouse_position).length_squared() < BOUNDS_SELECT_THRESHOLD.powi(2) {
|
||||||
|
overlay_context.hover_manipulator_anchor(pos, is_dragged);
|
||||||
|
} else {
|
||||||
|
overlay_context.square(pos, Some(6.), None, None);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some((layer, [start, end]))
|
// Store local-space positions for endpoint editing
|
||||||
|
Some((layer, [DVec2::ZERO, line_to]))
|
||||||
})
|
})
|
||||||
.collect::<HashMap<LayerNodeIdentifier, [DVec2; 2]>>();
|
.collect::<HashMap<LayerNodeIdentifier, [DVec2; 2]>>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_line(tool_data: &mut ShapeToolData, snap_data: SnapData, lock_angle: bool, snap_angle: bool, center: bool) -> [DVec2; 2] {
|
pub fn generate_line(tool_data: &mut ShapeToolData, snap_data: SnapData, lock_angle: bool, snap_angle: bool, center: bool) -> [DVec2; 2] {
|
||||||
let document_to_viewport = snap_data.document.metadata().document_to_viewport;
|
let document_to_viewport = snap_data.document.metadata().document_to_viewport;
|
||||||
let mut document_points = [tool_data.data.drag_start, document_to_viewport.inverse().transform_point2(tool_data.line_data.drag_current)];
|
let mut document_points = [tool_data.data.drag_start, document_to_viewport.inverse().transform_point2(tool_data.line_data.drag_current)];
|
||||||
|
|
||||||
@@ -172,36 +187,6 @@ fn generate_line(tool_data: &mut ShapeToolData, snap_data: SnapData, lock_angle:
|
|||||||
document_points
|
document_points
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clicked_on_line_endpoints(layer: LayerNodeIdentifier, document: &DocumentMessageHandler, input: &InputPreprocessorMessageHandler, shape_tool_data: &mut ShapeToolData) -> bool {
|
|
||||||
let Some(node_inputs) = NodeGraphLayer::new(layer, &document.network_interface).find_node_inputs(&DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::line::IDENTIFIER)) else {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
let (Some(&TaggedValue::DVec2(document_start)), Some(&TaggedValue::DVec2(document_end))) = (node_inputs[1].as_value(), node_inputs[2].as_value()) else {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
let transform = document.metadata().transform_to_viewport(layer);
|
|
||||||
let viewport_x = transform.transform_vector2(DVec2::X).normalize_or_zero() * BOUNDS_SELECT_THRESHOLD;
|
|
||||||
let viewport_y = transform.transform_vector2(DVec2::Y).normalize_or_zero() * BOUNDS_SELECT_THRESHOLD;
|
|
||||||
let threshold_x = transform.inverse().transform_vector2(viewport_x).length();
|
|
||||||
let threshold_y = transform.inverse().transform_vector2(viewport_y).length();
|
|
||||||
|
|
||||||
let drag_start = input.mouse.position;
|
|
||||||
let [start, end] = [document_start, document_end].map(|point| transform.transform_point2(point));
|
|
||||||
|
|
||||||
let start_click = (drag_start.y - start.y).abs() < threshold_y && (drag_start.x - start.x).abs() < threshold_x;
|
|
||||||
let end_click = (drag_start.y - end.y).abs() < threshold_y && (drag_start.x - end.x).abs() < threshold_x;
|
|
||||||
|
|
||||||
if start_click || end_click {
|
|
||||||
shape_tool_data.line_data.dragging_endpoint = Some(if end_click { LineEnd::End } else { LineEnd::Start });
|
|
||||||
shape_tool_data.data.drag_start = if end_click { document_start } else { document_end };
|
|
||||||
shape_tool_data.line_data.editing_layer = Some(layer);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_line_tool {
|
mod test_line_tool {
|
||||||
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
|
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
|
||||||
@@ -210,7 +195,9 @@ mod test_line_tool {
|
|||||||
use glam::DAffine2;
|
use glam::DAffine2;
|
||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
|
|
||||||
async fn get_line_node_inputs(editor: &mut EditorTestUtils) -> Option<(DVec2, DVec2)> {
|
/// Get the line's document-space start and end points by reading line_to from the node
|
||||||
|
/// and computing the actual positions via the layer's transform.
|
||||||
|
async fn get_line_endpoints_document(editor: &mut EditorTestUtils) -> Option<(DVec2, DVec2)> {
|
||||||
let document = editor.active_document();
|
let document = editor.active_document();
|
||||||
let network_interface = &document.network_interface;
|
let network_interface = &document.network_interface;
|
||||||
|
|
||||||
@@ -219,10 +206,14 @@ mod test_line_tool {
|
|||||||
.selected_visible_and_unlocked_layers(network_interface)
|
.selected_visible_and_unlocked_layers(network_interface)
|
||||||
.filter_map(|layer| {
|
.filter_map(|layer| {
|
||||||
let node_inputs = NodeGraphLayer::new(layer, network_interface).find_node_inputs(&DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::line::IDENTIFIER))?;
|
let node_inputs = NodeGraphLayer::new(layer, network_interface).find_node_inputs(&DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::line::IDENTIFIER))?;
|
||||||
let (Some(&TaggedValue::DVec2(start)), Some(&TaggedValue::DVec2(end))) = (node_inputs[1].as_value(), node_inputs[2].as_value()) else {
|
let Some(&TaggedValue::DVec2(line_to)) = node_inputs[1].as_value() else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
Some((start, end))
|
|
||||||
|
let transform_to_doc = document.metadata().transform_to_document(layer);
|
||||||
|
let doc_start = transform_to_doc.transform_point2(DVec2::ZERO);
|
||||||
|
let doc_end = transform_to_doc.transform_point2(line_to);
|
||||||
|
Some((doc_start, doc_end))
|
||||||
})
|
})
|
||||||
.next()
|
.next()
|
||||||
}
|
}
|
||||||
@@ -232,13 +223,9 @@ mod test_line_tool {
|
|||||||
let mut editor = EditorTestUtils::create();
|
let mut editor = EditorTestUtils::create();
|
||||||
editor.new_document().await;
|
editor.new_document().await;
|
||||||
editor.drag_tool(ToolType::Line, 0., 0., 100., 100., ModifierKeys::empty()).await;
|
editor.drag_tool(ToolType::Line, 0., 0., 100., 100., ModifierKeys::empty()).await;
|
||||||
if let Some((start_input, end_input)) = get_line_node_inputs(&mut editor).await {
|
if let Some((start, end)) = get_line_endpoints_document(&mut editor).await {
|
||||||
match (start_input, end_input) {
|
assert!((start - DVec2::ZERO).length() < 1., "Start point should be near (0,0)");
|
||||||
(start_input, end_input) => {
|
assert!((end - DVec2::new(100., 100.)).length() < 1., "End point should be near (100,100)");
|
||||||
assert!((start_input - DVec2::ZERO).length() < 1., "Start point should be near (0,0)");
|
|
||||||
assert!((end_input - DVec2::new(100., 100.)).length() < 1., "End point should be near (100,100)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +237,7 @@ mod test_line_tool {
|
|||||||
editor.handle_message(NavigationMessage::CanvasPan { delta: DVec2::new(100., 50.) }).await;
|
editor.handle_message(NavigationMessage::CanvasPan { delta: DVec2::new(100., 50.) }).await;
|
||||||
editor.handle_message(NavigationMessage::CanvasTiltSet { angle_radians: 30_f64.to_radians() }).await;
|
editor.handle_message(NavigationMessage::CanvasTiltSet { angle_radians: 30_f64.to_radians() }).await;
|
||||||
editor.drag_tool(ToolType::Line, 0., 0., 100., 100., ModifierKeys::empty()).await;
|
editor.drag_tool(ToolType::Line, 0., 0., 100., 100., ModifierKeys::empty()).await;
|
||||||
if let Some((start_input, end_input)) = get_line_node_inputs(&mut editor).await {
|
if let Some((start, end)) = get_line_endpoints_document(&mut editor).await {
|
||||||
let document = editor.active_document();
|
let document = editor.active_document();
|
||||||
let document_to_viewport = document.metadata().document_to_viewport;
|
let document_to_viewport = document.metadata().document_to_viewport;
|
||||||
let viewport_to_document = document_to_viewport.inverse();
|
let viewport_to_document = document_to_viewport.inverse();
|
||||||
@@ -259,12 +246,12 @@ mod test_line_tool {
|
|||||||
let expected_end = viewport_to_document.transform_point2(DVec2::new(100., 100.));
|
let expected_end = viewport_to_document.transform_point2(DVec2::new(100., 100.));
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
(start_input - expected_start).length() < 1.,
|
(start - expected_start).length() < 1.,
|
||||||
"Start point should match expected document coordinates. Got {start_input:?}, expected {expected_start:?}"
|
"Start point should match expected document coordinates. Got {start:?}, expected {expected_start:?}"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
(end_input - expected_end).length() < 1.,
|
(end - expected_end).length() < 1.,
|
||||||
"End point should match expected document coordinates. Got {end_input:?}, expected {expected_end:?}"
|
"End point should match expected document coordinates. Got {end:?}, expected {expected_end:?}"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
panic!("Line was not created successfully with transformed viewport");
|
panic!("Line was not created successfully with transformed viewport");
|
||||||
@@ -276,11 +263,11 @@ mod test_line_tool {
|
|||||||
let mut editor = EditorTestUtils::create();
|
let mut editor = EditorTestUtils::create();
|
||||||
editor.new_document().await;
|
editor.new_document().await;
|
||||||
editor.drag_tool(ToolType::Line, 0., 0., 100., 100., ModifierKeys::CONTROL).await;
|
editor.drag_tool(ToolType::Line, 0., 0., 100., 100., ModifierKeys::CONTROL).await;
|
||||||
if let Some((start_input, end_input)) = get_line_node_inputs(&mut editor).await {
|
if let Some((start, end)) = get_line_endpoints_document(&mut editor).await {
|
||||||
let line_vec = end_input - start_input;
|
let line_vec = end - start;
|
||||||
let original_angle = line_vec.angle_to(DVec2::X);
|
let original_angle = line_vec.angle_to(DVec2::X);
|
||||||
editor.drag_tool(ToolType::Line, 0., 0., 200., 50., ModifierKeys::CONTROL).await;
|
editor.drag_tool(ToolType::Line, 0., 0., 200., 50., ModifierKeys::CONTROL).await;
|
||||||
if let Some((updated_start, updated_end)) = get_line_node_inputs(&mut editor).await {
|
if let Some((updated_start, updated_end)) = get_line_endpoints_document(&mut editor).await {
|
||||||
let updated_line_vec = updated_end - updated_start;
|
let updated_line_vec = updated_end - updated_start;
|
||||||
let updated_angle = updated_line_vec.angle_to(DVec2::X);
|
let updated_angle = updated_line_vec.angle_to(DVec2::X);
|
||||||
print!("{original_angle:?}");
|
print!("{original_angle:?}");
|
||||||
@@ -299,11 +286,11 @@ mod test_line_tool {
|
|||||||
let mut editor = EditorTestUtils::create();
|
let mut editor = EditorTestUtils::create();
|
||||||
editor.new_document().await;
|
editor.new_document().await;
|
||||||
editor.drag_tool(ToolType::Line, 100., 100., 200., 100., ModifierKeys::ALT).await;
|
editor.drag_tool(ToolType::Line, 100., 100., 200., 100., ModifierKeys::ALT).await;
|
||||||
if let Some((start_input, end_input)) = get_line_node_inputs(&mut editor).await {
|
if let Some((start, end)) = get_line_endpoints_document(&mut editor).await {
|
||||||
let expected_start = DVec2::new(0., 100.);
|
let expected_start = DVec2::new(0., 100.);
|
||||||
let expected_end = DVec2::new(200., 100.);
|
let expected_end = DVec2::new(200., 100.);
|
||||||
assert!((start_input - expected_start).length() < 1., "Start point should be near (0, 100)");
|
assert!((start - expected_start).length() < 1., "Start point should be near (0, 100)");
|
||||||
assert!((end_input - expected_end).length() < 1., "End point should be near (200, 100)");
|
assert!((end - expected_end).length() < 1., "End point should be near (200, 100)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,17 +299,13 @@ mod test_line_tool {
|
|||||||
let mut editor = EditorTestUtils::create();
|
let mut editor = EditorTestUtils::create();
|
||||||
editor.new_document().await;
|
editor.new_document().await;
|
||||||
editor.drag_tool(ToolType::Line, 100., 100., 150., 120., ModifierKeys::ALT | ModifierKeys::SHIFT).await;
|
editor.drag_tool(ToolType::Line, 100., 100., 150., 120., ModifierKeys::ALT | ModifierKeys::SHIFT).await;
|
||||||
if let Some((start_input, end_input)) = get_line_node_inputs(&mut editor).await {
|
if let Some((start, end)) = get_line_endpoints_document(&mut editor).await {
|
||||||
match (start_input, end_input) {
|
let line_vec = end - start;
|
||||||
(start_input, end_input) => {
|
let angle_radians = line_vec.angle_to(DVec2::X);
|
||||||
let line_vec = end_input - start_input;
|
let angle_degrees = angle_radians.to_degrees();
|
||||||
let angle_radians = line_vec.angle_to(DVec2::X);
|
let nearest_angle = (angle_degrees / 15.).round() * 15.;
|
||||||
let angle_degrees = angle_radians.to_degrees();
|
|
||||||
let nearest_angle = (angle_degrees / 15.).round() * 15.;
|
|
||||||
|
|
||||||
assert!((angle_degrees - nearest_angle).abs() < 1., "Angle should snap to the nearest 15 degrees");
|
assert!((angle_degrees - nearest_angle).abs() < 1., "Angle should snap to the nearest 15 degrees");
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,9 +328,9 @@ mod test_line_tool {
|
|||||||
|
|
||||||
editor.drag_tool(ToolType::Line, 50., 50., 150., 150., ModifierKeys::empty()).await;
|
editor.drag_tool(ToolType::Line, 50., 50., 150., 150., ModifierKeys::empty()).await;
|
||||||
|
|
||||||
let (start_input, end_input) = get_line_node_inputs(&mut editor).await.expect("Line was not created successfully within transformed artboard");
|
let (start, end) = get_line_endpoints_document(&mut editor).await.expect("Line was not created successfully within transformed artboard");
|
||||||
// The line should still be diagonal with equal change in x and y
|
// The line should still be diagonal with equal change in x and y
|
||||||
let line_vector = end_input - start_input;
|
let line_vector = end - start;
|
||||||
// Verifying the line is approximately 100*sqrt(2) units in length (diagonal of 100x100 square)
|
// Verifying the line is approximately 100*sqrt(2) units in length (diagonal of 100x100 square)
|
||||||
let line_length = line_vector.length();
|
let line_length = line_vector.length();
|
||||||
assert!(
|
assert!(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use super::ShapeToolData;
|
use super::ShapeToolData;
|
||||||
use crate::consts::{ARC_SWEEP_GIZMO_RADIUS, ARC_SWEEP_GIZMO_TEXT_HEIGHT};
|
use super::line_shape::LineEnd;
|
||||||
|
use crate::consts::{ARC_SWEEP_GIZMO_RADIUS, ARC_SWEEP_GIZMO_TEXT_HEIGHT, BOUNDS_SELECT_THRESHOLD};
|
||||||
use crate::messages::frontend::utility_types::MouseCursorIcon;
|
use crate::messages::frontend::utility_types::MouseCursorIcon;
|
||||||
use crate::messages::message::Message;
|
use crate::messages::message::Message;
|
||||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier;
|
use crate::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier;
|
||||||
@@ -23,7 +24,8 @@ use kurbo::{BezPath, PathEl, Shape};
|
|||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::f64::consts::{PI, TAU};
|
use std::f64::consts::{PI, TAU};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ShapeType {
|
pub enum ShapeType {
|
||||||
#[default]
|
#[default]
|
||||||
Polygon = 0,
|
Polygon = 0,
|
||||||
@@ -32,10 +34,10 @@ pub enum ShapeType {
|
|||||||
Arc,
|
Arc,
|
||||||
Spiral,
|
Spiral,
|
||||||
Grid,
|
Grid,
|
||||||
Rectangle,
|
|
||||||
Ellipse,
|
|
||||||
Arrow,
|
Arrow,
|
||||||
Line,
|
Line, // KEEP THIS AT THE END
|
||||||
|
Rectangle, // KEEP THIS AT THE END
|
||||||
|
Ellipse, // KEEP THIS AT THE END
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShapeType {
|
impl ShapeType {
|
||||||
@@ -45,12 +47,12 @@ impl ShapeType {
|
|||||||
Self::Star => "Star",
|
Self::Star => "Star",
|
||||||
Self::Circle => "Circle",
|
Self::Circle => "Circle",
|
||||||
Self::Arc => "Arc",
|
Self::Arc => "Arc",
|
||||||
Self::Grid => "Grid",
|
|
||||||
Self::Spiral => "Spiral",
|
Self::Spiral => "Spiral",
|
||||||
Self::Rectangle => "Rectangle",
|
Self::Grid => "Grid",
|
||||||
Self::Ellipse => "Ellipse",
|
|
||||||
Self::Arrow => "Arrow",
|
Self::Arrow => "Arrow",
|
||||||
Self::Line => "Line",
|
Self::Line => "Line",
|
||||||
|
Self::Rectangle => "Rectangle",
|
||||||
|
Self::Ellipse => "Ellipse",
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
@@ -60,7 +62,6 @@ impl ShapeType {
|
|||||||
Self::Line => "Line Tool",
|
Self::Line => "Line Tool",
|
||||||
Self::Rectangle => "Rectangle Tool",
|
Self::Rectangle => "Rectangle Tool",
|
||||||
Self::Ellipse => "Ellipse Tool",
|
Self::Ellipse => "Ellipse Tool",
|
||||||
Self::Arrow => "Arrow Tool",
|
|
||||||
_ => "",
|
_ => "",
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
@@ -79,7 +80,6 @@ impl ShapeType {
|
|||||||
Self::Line => "VectorLineTool",
|
Self::Line => "VectorLineTool",
|
||||||
Self::Rectangle => "VectorRectangleTool",
|
Self::Rectangle => "VectorRectangleTool",
|
||||||
Self::Ellipse => "VectorEllipseTool",
|
Self::Ellipse => "VectorEllipseTool",
|
||||||
Self::Arrow => "VectorArrowTool",
|
|
||||||
_ => "",
|
_ => "",
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
@@ -90,7 +90,6 @@ impl ShapeType {
|
|||||||
Self::Line => ToolType::Line,
|
Self::Line => ToolType::Line,
|
||||||
Self::Rectangle => ToolType::Rectangle,
|
Self::Rectangle => ToolType::Rectangle,
|
||||||
Self::Ellipse => ToolType::Ellipse,
|
Self::Ellipse => ToolType::Ellipse,
|
||||||
Self::Arrow => ToolType::Shape,
|
|
||||||
_ => ToolType::Shape,
|
_ => ToolType::Shape,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,6 +152,42 @@ pub trait ShapeGizmoHandler {
|
|||||||
fn mouse_cursor_icon(&self) -> Option<MouseCursorIcon>;
|
fn mouse_cursor_icon(&self) -> Option<MouseCursorIcon>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if the mouse clicked on either endpoint of a line-like shape (Line or Arrow).
|
||||||
|
pub fn clicked_on_shape_endpoints(layer: LayerNodeIdentifier, document: &DocumentMessageHandler, input: &InputPreprocessorMessageHandler, shape_tool_data: &mut ShapeToolData) -> bool {
|
||||||
|
let line_like_shape_nodes = [
|
||||||
|
DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::line::IDENTIFIER),
|
||||||
|
DefinitionIdentifier::ProtoNode(graphene_std::vector_nodes::arrow::IDENTIFIER),
|
||||||
|
];
|
||||||
|
|
||||||
|
let node_graph_layer = NodeGraphLayer::new(layer, &document.network_interface);
|
||||||
|
let endpoint = line_like_shape_nodes.iter().find_map(|id| {
|
||||||
|
let node_inputs = node_graph_layer.find_node_inputs(id)?;
|
||||||
|
let &TaggedValue::DVec2(endpoint) = node_inputs[1].as_value()? else { return None };
|
||||||
|
Some(endpoint)
|
||||||
|
});
|
||||||
|
let Some(endpoint) = endpoint else { return false };
|
||||||
|
|
||||||
|
let local_start = DVec2::ZERO;
|
||||||
|
let local_end = endpoint;
|
||||||
|
|
||||||
|
let transform = document.metadata().transform_to_viewport(layer);
|
||||||
|
let mouse_pos = input.mouse.position;
|
||||||
|
let [start, end] = [local_start, local_end].map(|point| transform.transform_point2(point));
|
||||||
|
|
||||||
|
let start_click = (mouse_pos - start).length_squared() < BOUNDS_SELECT_THRESHOLD.powi(2);
|
||||||
|
let end_click = (mouse_pos - end).length_squared() < BOUNDS_SELECT_THRESHOLD.powi(2);
|
||||||
|
let endpoint_click = start_click || end_click;
|
||||||
|
|
||||||
|
if endpoint_click {
|
||||||
|
shape_tool_data.line_data.dragging_endpoint = Some(if end_click { LineEnd::End } else { LineEnd::Start });
|
||||||
|
let anchor_local = if end_click { local_start } else { local_end };
|
||||||
|
shape_tool_data.data.drag_start = document.metadata().transform_to_document(layer).transform_point2(anchor_local);
|
||||||
|
shape_tool_data.line_data.editing_layer = Some(layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
endpoint_click
|
||||||
|
}
|
||||||
|
|
||||||
/// Center, Lock Ratio, Lock Angle, Snap Angle, Increase/Decrease Side
|
/// Center, Lock Ratio, Lock Angle, Snap Angle, Increase/Decrease Side
|
||||||
pub fn update_radius_sign(end: DVec2, start: DVec2, layer: LayerNodeIdentifier, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) {
|
pub fn update_radius_sign(end: DVec2, start: DVec2, layer: LayerNodeIdentifier, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) {
|
||||||
let sign_num = if end[1] > start[1] { 1. } else { -1. };
|
let sign_num = if end[1] > start[1] { 1. } else { -1. };
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use super::common_functionality::shape_editor::ShapeState;
|
use super::common_functionality::shape_editor::ShapeState;
|
||||||
use super::common_functionality::shapes::shape_utility::ShapeType::{self, Ellipse, Line, Rectangle};
|
use super::common_functionality::shapes::shape_utility::ShapeType::{Ellipse, Line, Rectangle};
|
||||||
use super::utility_types::{ToolActionMessageContext, ToolFsmState, tool_message_to_tool_type};
|
use super::utility_types::{ToolActionMessageContext, ToolFsmState, tool_message_to_tool_type};
|
||||||
use crate::application::generate_uuid;
|
use crate::application::generate_uuid;
|
||||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||||
@@ -77,7 +77,8 @@ impl MessageHandler<ToolMessage, ToolMessageContext<'_>> for ToolMessageHandler
|
|||||||
self.tool_state.tool_data.active_tool_type = ToolType::Shape;
|
self.tool_state.tool_data.active_tool_type = ToolType::Shape;
|
||||||
}
|
}
|
||||||
responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Shape });
|
responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Shape });
|
||||||
responses.add(ShapeToolMessage::SetShape { shape: ShapeType::Polygon });
|
// Sync current_shape with the dropdown selection (options.shape_type)
|
||||||
|
responses.add(ShapeToolMessage::SyncShapeWithOptions);
|
||||||
responses.add(ShapeToolMessage::HideShapeTypeWidget { hide: false })
|
responses.add(ShapeToolMessage::HideShapeTypeWidget { hide: false })
|
||||||
}
|
}
|
||||||
ToolMessage::ActivateToolBrush => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Brush }),
|
ToolMessage::ActivateToolBrush => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Brush }),
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ pub struct ArtboardTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Artboard)]
|
#[impl_message(Message, ToolMessage, Artboard)]
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ArtboardToolMessage {
|
pub enum ArtboardToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Abort,
|
Abort,
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ use graphene_std::raster::BlendMode;
|
|||||||
|
|
||||||
const BRUSH_MAX_SIZE: f64 = 5000.;
|
const BRUSH_MAX_SIZE: f64 = 5000.;
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum DrawMode {
|
pub enum DrawMode {
|
||||||
Draw = 0,
|
Draw = 0,
|
||||||
Erase,
|
Erase,
|
||||||
@@ -52,7 +53,8 @@ impl Default for BrushOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Brush)]
|
#[impl_message(Message, ToolMessage, Brush)]
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum BrushToolMessage {
|
pub enum BrushToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Abort,
|
Abort,
|
||||||
@@ -65,7 +67,8 @@ pub enum BrushToolMessage {
|
|||||||
UpdateOptions { options: BrushToolMessageOptionsUpdate },
|
UpdateOptions { options: BrushToolMessageOptionsUpdate },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum BrushToolMessageOptionsUpdate {
|
pub enum BrushToolMessageOptionsUpdate {
|
||||||
BlendMode(BlendMode),
|
BlendMode(BlendMode),
|
||||||
ChangeDiameter(f64),
|
ChangeDiameter(f64),
|
||||||
@@ -220,7 +223,7 @@ impl LayoutHolder for BrushTool {
|
|||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use super::tool_prelude::*;
|
use super::tool_prelude::*;
|
||||||
use crate::messages::frontend::utility_types::EyedropperPreviewImage;
|
use crate::messages::frontend::utility_types::EyedropperPreviewImage;
|
||||||
use crate::messages::tool::utility_types::DocumentToolData;
|
use crate::messages::tool::utility_types::DocumentToolData;
|
||||||
|
use graphene_std::vector::style::RenderMode;
|
||||||
|
|
||||||
#[derive(Default, ExtractField)]
|
#[derive(Default, ExtractField)]
|
||||||
pub struct EyedropperTool {
|
pub struct EyedropperTool {
|
||||||
@@ -9,7 +10,8 @@ pub struct EyedropperTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Eyedropper)]
|
#[impl_message(Message, ToolMessage, Eyedropper)]
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum EyedropperToolMessage {
|
pub enum EyedropperToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Abort,
|
Abort,
|
||||||
@@ -46,9 +48,9 @@ impl LayoutHolder for EyedropperTool {
|
|||||||
impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for EyedropperTool {
|
impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for EyedropperTool {
|
||||||
fn process_message(&mut self, message: ToolMessage, responses: &mut VecDeque<Message>, context: &mut ToolActionMessageContext<'a>) {
|
fn process_message(&mut self, message: ToolMessage, responses: &mut VecDeque<Message>, context: &mut ToolActionMessageContext<'a>) {
|
||||||
if let ToolMessage::Eyedropper(EyedropperToolMessage::PreviewImage { data, width, height }) = message {
|
if let ToolMessage::Eyedropper(EyedropperToolMessage::PreviewImage { data, width, height }) = message {
|
||||||
let image = EyedropperPreviewImage { data, width, height };
|
let image = EyedropperPreviewImage { data: data.into(), width, height };
|
||||||
|
|
||||||
update_cursor_preview_common(responses, Some(image), context.input, context.global_tool_data, self.data.color_choice.clone());
|
update_cursor_preview_common(responses, Some(image), context.input, context.global_tool_data, self.data.color_choice);
|
||||||
|
|
||||||
if !self.data.preview {
|
if !self.data.preview {
|
||||||
disable_cursor_preview(responses, &mut self.data);
|
disable_cursor_preview(responses, &mut self.data);
|
||||||
@@ -87,10 +89,18 @@ enum EyedropperToolFsmState {
|
|||||||
SamplingSecondary,
|
SamplingSecondary,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub enum PrimarySecondary {
|
||||||
|
#[default]
|
||||||
|
Primary,
|
||||||
|
Secondary,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
struct EyedropperToolData {
|
struct EyedropperToolData {
|
||||||
preview: bool,
|
preview: bool,
|
||||||
color_choice: Option<String>,
|
color_choice: Option<PrimarySecondary>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Fsm for EyedropperToolFsmState {
|
impl Fsm for EyedropperToolFsmState {
|
||||||
@@ -99,14 +109,19 @@ impl Fsm for EyedropperToolFsmState {
|
|||||||
|
|
||||||
fn transition(self, event: ToolMessage, tool_data: &mut Self::ToolData, tool_action_data: &mut ToolActionMessageContext, _tool_options: &(), responses: &mut VecDeque<Message>) -> Self {
|
fn transition(self, event: ToolMessage, tool_data: &mut Self::ToolData, tool_action_data: &mut ToolActionMessageContext, _tool_options: &(), responses: &mut VecDeque<Message>) -> Self {
|
||||||
let ToolActionMessageContext {
|
let ToolActionMessageContext {
|
||||||
global_tool_data, input, viewport, ..
|
document,
|
||||||
|
global_tool_data,
|
||||||
|
input,
|
||||||
|
viewport,
|
||||||
|
..
|
||||||
} = tool_action_data;
|
} = tool_action_data;
|
||||||
|
let render_mode = document.render_mode;
|
||||||
|
|
||||||
let ToolMessage::Eyedropper(event) = event else { return self };
|
let ToolMessage::Eyedropper(event) = event else { return self };
|
||||||
match (self, event) {
|
match (self, event) {
|
||||||
// Ready -> Sampling
|
// Ready -> Sampling
|
||||||
(EyedropperToolFsmState::Ready, mouse_down) if matches!(mouse_down, EyedropperToolMessage::SamplePrimaryColorBegin | EyedropperToolMessage::SampleSecondaryColorBegin) => {
|
(EyedropperToolFsmState::Ready, mouse_down) if matches!(mouse_down, EyedropperToolMessage::SamplePrimaryColorBegin | EyedropperToolMessage::SampleSecondaryColorBegin) => {
|
||||||
update_cursor_preview(responses, tool_data, input, global_tool_data, None);
|
update_cursor_preview(responses, tool_data, input, global_tool_data, None, render_mode);
|
||||||
|
|
||||||
if mouse_down == EyedropperToolMessage::SamplePrimaryColorBegin {
|
if mouse_down == EyedropperToolMessage::SamplePrimaryColorBegin {
|
||||||
EyedropperToolFsmState::SamplingPrimary
|
EyedropperToolFsmState::SamplingPrimary
|
||||||
@@ -118,7 +133,7 @@ impl Fsm for EyedropperToolFsmState {
|
|||||||
(EyedropperToolFsmState::SamplingPrimary | EyedropperToolFsmState::SamplingSecondary, EyedropperToolMessage::PointerMove) => {
|
(EyedropperToolFsmState::SamplingPrimary | EyedropperToolFsmState::SamplingSecondary, EyedropperToolMessage::PointerMove) => {
|
||||||
let mouse_position = viewport.logical(input.mouse.position);
|
let mouse_position = viewport.logical(input.mouse.position);
|
||||||
if viewport.is_in_bounds(mouse_position + viewport.offset()) {
|
if viewport.is_in_bounds(mouse_position + viewport.offset()) {
|
||||||
update_cursor_preview(responses, tool_data, input, global_tool_data, None);
|
update_cursor_preview(responses, tool_data, input, global_tool_data, None, render_mode);
|
||||||
} else {
|
} else {
|
||||||
disable_cursor_preview(responses, tool_data);
|
disable_cursor_preview(responses, tool_data);
|
||||||
}
|
}
|
||||||
@@ -127,8 +142,12 @@ impl Fsm for EyedropperToolFsmState {
|
|||||||
}
|
}
|
||||||
// Sampling -> Ready
|
// Sampling -> Ready
|
||||||
(EyedropperToolFsmState::SamplingPrimary, EyedropperToolMessage::SamplePrimaryColorEnd) | (EyedropperToolFsmState::SamplingSecondary, EyedropperToolMessage::SampleSecondaryColorEnd) => {
|
(EyedropperToolFsmState::SamplingPrimary, EyedropperToolMessage::SamplePrimaryColorEnd) | (EyedropperToolFsmState::SamplingSecondary, EyedropperToolMessage::SampleSecondaryColorEnd) => {
|
||||||
let set_color_choice = if self == EyedropperToolFsmState::SamplingPrimary { "Primary" } else { "Secondary" }.to_string();
|
let set_color_choice = match self {
|
||||||
update_cursor_preview(responses, tool_data, input, global_tool_data, Some(set_color_choice));
|
EyedropperToolFsmState::SamplingPrimary => PrimarySecondary::Primary,
|
||||||
|
EyedropperToolFsmState::SamplingSecondary => PrimarySecondary::Secondary,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
update_cursor_preview(responses, tool_data, input, global_tool_data, Some(set_color_choice), render_mode);
|
||||||
disable_cursor_preview(responses, tool_data);
|
disable_cursor_preview(responses, tool_data);
|
||||||
|
|
||||||
EyedropperToolFsmState::Ready
|
EyedropperToolFsmState::Ready
|
||||||
@@ -179,31 +198,29 @@ fn disable_cursor_preview(responses: &mut VecDeque<Message>, tool_data: &mut Eye
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_family = "wasm"))]
|
|
||||||
fn update_cursor_preview(
|
|
||||||
responses: &mut VecDeque<Message>,
|
|
||||||
tool_data: &mut EyedropperToolData,
|
|
||||||
_input: &InputPreprocessorMessageHandler,
|
|
||||||
_global_tool_data: &DocumentToolData,
|
|
||||||
set_color_choice: Option<String>,
|
|
||||||
) {
|
|
||||||
tool_data.preview = true;
|
|
||||||
tool_data.color_choice = set_color_choice;
|
|
||||||
responses.add(PortfolioMessage::SubmitEyedropperPreviewRender);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_family = "wasm")]
|
|
||||||
fn update_cursor_preview(
|
fn update_cursor_preview(
|
||||||
responses: &mut VecDeque<Message>,
|
responses: &mut VecDeque<Message>,
|
||||||
tool_data: &mut EyedropperToolData,
|
tool_data: &mut EyedropperToolData,
|
||||||
input: &InputPreprocessorMessageHandler,
|
input: &InputPreprocessorMessageHandler,
|
||||||
global_tool_data: &DocumentToolData,
|
global_tool_data: &DocumentToolData,
|
||||||
set_color_choice: Option<String>,
|
set_color_choice: Option<PrimarySecondary>,
|
||||||
|
render_mode: RenderMode,
|
||||||
) {
|
) {
|
||||||
tool_data.preview = true;
|
tool_data.preview = true;
|
||||||
tool_data.color_choice = set_color_choice.clone();
|
tool_data.color_choice = set_color_choice;
|
||||||
|
|
||||||
update_cursor_preview_common(responses, None, input, global_tool_data, set_color_choice);
|
// On web, SVG Preview mode uses the frontend's SVG rasterization to sample pixels directly
|
||||||
|
#[cfg(target_family = "wasm")]
|
||||||
|
if render_mode == RenderMode::SvgPreview {
|
||||||
|
update_cursor_preview_common(responses, None, input, global_tool_data, set_color_choice);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = (&input, &global_tool_data, &render_mode);
|
||||||
|
|
||||||
|
// For Vello-rendered modes (Normal, Outline, and Pixel Preview), submit a backend render request
|
||||||
|
// which will return a zoomed-in pixel preview image via the EyedropperToolMessage::PreviewImage path
|
||||||
|
responses.add(PortfolioMessage::SubmitEyedropperPreviewRender);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_cursor_preview_common(
|
fn update_cursor_preview_common(
|
||||||
@@ -211,7 +228,7 @@ fn update_cursor_preview_common(
|
|||||||
image: Option<EyedropperPreviewImage>,
|
image: Option<EyedropperPreviewImage>,
|
||||||
input: &InputPreprocessorMessageHandler,
|
input: &InputPreprocessorMessageHandler,
|
||||||
global_tool_data: &DocumentToolData,
|
global_tool_data: &DocumentToolData,
|
||||||
set_color_choice: Option<String>,
|
set_color_choice: Option<PrimarySecondary>,
|
||||||
) {
|
) {
|
||||||
responses.add(FrontendMessage::UpdateEyedropperSamplingState {
|
responses.add(FrontendMessage::UpdateEyedropperSamplingState {
|
||||||
image,
|
image,
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ pub struct FillTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Fill)]
|
#[impl_message(Message, ToolMessage, Fill)]
|
||||||
#[derive(PartialEq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum FillToolMessage {
|
pub enum FillToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Abort,
|
Abort,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use super::tool_prelude::*;
|
use super::tool_prelude::*;
|
||||||
use crate::consts::DEFAULT_STROKE_WIDTH;
|
use crate::consts::DEFAULT_STROKE_WIDTH;
|
||||||
|
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
|
||||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_network_node_type;
|
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_network_node_type;
|
||||||
use crate::messages::portfolio::document::overlays::utility_functions::path_endpoint_overlays;
|
use crate::messages::portfolio::document::overlays::utility_functions::path_endpoint_overlays;
|
||||||
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
||||||
@@ -37,7 +38,8 @@ impl Default for FreehandOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Freehand)]
|
#[impl_message(Message, ToolMessage, Freehand)]
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum FreehandToolMessage {
|
pub enum FreehandToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Overlays { context: OverlayContext },
|
Overlays { context: OverlayContext },
|
||||||
@@ -51,7 +53,8 @@ pub enum FreehandToolMessage {
|
|||||||
UpdateOptions { options: FreehandOptionsUpdate },
|
UpdateOptions { options: FreehandOptionsUpdate },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum FreehandOptionsUpdate {
|
pub enum FreehandOptionsUpdate {
|
||||||
FillColor(Option<Color>),
|
FillColor(Option<Color>),
|
||||||
FillColorType(ToolColorType),
|
FillColorType(ToolColorType),
|
||||||
@@ -151,7 +154,7 @@ impl LayoutHolder for FreehandTool {
|
|||||||
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
|
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
|
||||||
widgets.push(create_weight_widget(self.options.line_weight));
|
widgets.push(create_weight_widget(self.options.line_weight));
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,6 +220,9 @@ struct FreehandToolData {
|
|||||||
dragged: bool,
|
dragged: bool,
|
||||||
weight: f64,
|
weight: f64,
|
||||||
layer: Option<LayerNodeIdentifier>,
|
layer: Option<LayerNodeIdentifier>,
|
||||||
|
/// Viewport-space start position for newly created layers, used to compute local-space
|
||||||
|
/// positions before the deferred TransformSet has been reflected in metadata.
|
||||||
|
new_layer_viewport_start: Option<DVec2>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Fsm for FreehandToolFsmState {
|
impl Fsm for FreehandToolFsmState {
|
||||||
@@ -253,6 +259,7 @@ impl Fsm for FreehandToolFsmState {
|
|||||||
tool_data.dragged = false;
|
tool_data.dragged = false;
|
||||||
tool_data.end_point = None;
|
tool_data.end_point = None;
|
||||||
tool_data.weight = tool_options.line_weight;
|
tool_data.weight = tool_options.line_weight;
|
||||||
|
tool_data.new_layer_viewport_start = None;
|
||||||
|
|
||||||
// Extend an endpoint of the selected path
|
// Extend an endpoint of the selected path
|
||||||
let selected_nodes = document.network_interface.selected_nodes();
|
let selected_nodes = document.network_interface.selected_nodes();
|
||||||
@@ -293,13 +300,42 @@ impl Fsm for FreehandToolFsmState {
|
|||||||
tool_options.stroke.apply_stroke(tool_data.weight, layer, responses);
|
tool_options.stroke.apply_stroke(tool_data.weight, layer, responses);
|
||||||
tool_options.fill.apply_fill(layer, responses);
|
tool_options.fill.apply_fill(layer, responses);
|
||||||
tool_data.layer = Some(layer);
|
tool_data.layer = Some(layer);
|
||||||
|
tool_data.new_layer_viewport_start = Some(input.mouse.position);
|
||||||
|
|
||||||
|
// Position the layer at the initial mouse position via Transform
|
||||||
|
responses.add(DeferMessage::AfterGraphRun {
|
||||||
|
messages: vec![
|
||||||
|
GraphOperationMessage::TransformSet {
|
||||||
|
layer,
|
||||||
|
transform: DAffine2::from_translation(input.mouse.position),
|
||||||
|
transform_in: TransformIn::Viewport,
|
||||||
|
skip_rerender: false,
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
NodeGraphMessage::RunDocumentGraph.into(),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
FreehandToolFsmState::Drawing
|
FreehandToolFsmState::Drawing
|
||||||
}
|
}
|
||||||
(FreehandToolFsmState::Drawing, FreehandToolMessage::PointerMove) => {
|
(FreehandToolFsmState::Drawing, FreehandToolMessage::PointerMove) => {
|
||||||
if let Some(layer) = tool_data.layer {
|
if let Some(layer) = tool_data.layer {
|
||||||
let transform = document.metadata().transform_to_viewport(layer);
|
let transform = document.metadata().transform_to_viewport(layer);
|
||||||
let position = transform.inverse().transform_point2(input.mouse.position);
|
|
||||||
|
// For newly created layers, the deferred TransformSet may not yet be reflected
|
||||||
|
// in the metadata, so compute local position from the known viewport start.
|
||||||
|
// Once the metadata catches up (origin maps to start), switch to using it so
|
||||||
|
// that mid-stroke pan/tilt/zoom works correctly.
|
||||||
|
if let Some(start) = tool_data.new_layer_viewport_start
|
||||||
|
&& transform.transform_point2(DVec2::ZERO).abs_diff_eq(start, 1e-5)
|
||||||
|
{
|
||||||
|
tool_data.new_layer_viewport_start = None;
|
||||||
|
}
|
||||||
|
let position = if let Some(start) = tool_data.new_layer_viewport_start {
|
||||||
|
input.mouse.position - start
|
||||||
|
} else {
|
||||||
|
transform.inverse().transform_point2(input.mouse.position)
|
||||||
|
};
|
||||||
|
|
||||||
extend_path_with_next_segment(tool_data, position, true, responses);
|
extend_path_with_next_segment(tool_data, position, true, responses);
|
||||||
}
|
}
|
||||||
@@ -315,6 +351,7 @@ impl Fsm for FreehandToolFsmState {
|
|||||||
|
|
||||||
tool_data.end_point = None;
|
tool_data.end_point = None;
|
||||||
tool_data.layer = None;
|
tool_data.layer = None;
|
||||||
|
tool_data.new_layer_viewport_start = None;
|
||||||
|
|
||||||
FreehandToolFsmState::Ready
|
FreehandToolFsmState::Ready
|
||||||
}
|
}
|
||||||
@@ -322,6 +359,7 @@ impl Fsm for FreehandToolFsmState {
|
|||||||
responses.add(DocumentMessage::AbortTransaction);
|
responses.add(DocumentMessage::AbortTransaction);
|
||||||
tool_data.layer = None;
|
tool_data.layer = None;
|
||||||
tool_data.end_point = None;
|
tool_data.end_point = None;
|
||||||
|
tool_data.new_layer_viewport_start = None;
|
||||||
|
|
||||||
FreehandToolFsmState::Ready
|
FreehandToolFsmState::Ready
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ pub struct GradientOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Gradient)]
|
#[impl_message(Message, ToolMessage, Gradient)]
|
||||||
#[derive(PartialEq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum GradientToolMessage {
|
pub enum GradientToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Abort,
|
Abort,
|
||||||
@@ -46,7 +47,8 @@ pub enum GradientToolMessage {
|
|||||||
UpdateOptions { options: GradientOptionsUpdate },
|
UpdateOptions { options: GradientOptionsUpdate },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum GradientOptionsUpdate {
|
pub enum GradientOptionsUpdate {
|
||||||
Type(GradientType),
|
Type(GradientType),
|
||||||
ReverseStops,
|
ReverseStops,
|
||||||
@@ -199,7 +201,7 @@ impl LayoutHolder for GradientTool {
|
|||||||
widgets.push(reverse_direction);
|
widgets.push(reverse_direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,8 +772,8 @@ impl Fsm for GradientToolFsmState {
|
|||||||
if stop_index < gradient.stops.position.len() {
|
if stop_index < gradient.stops.position.len() {
|
||||||
let color = gradient.stops.color[stop_index].to_gamma_srgb();
|
let color = gradient.stops.color[stop_index].to_gamma_srgb();
|
||||||
let position = gradient.stops.position[stop_index];
|
let position = gradient.stops.position[stop_index];
|
||||||
let DVec2 { x, y } = transform.transform_point2(gradient.start.lerp(gradient.end, position));
|
let position = transform.transform_point2(gradient.start.lerp(gradient.end, position)).into();
|
||||||
responses.add(FrontendMessage::UpdateGradientStopColorPickerPosition { color, x, y });
|
responses.add(FrontendMessage::UpdateGradientStopColorPickerPosition { color, position });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -824,13 +826,10 @@ impl Fsm for GradientToolFsmState {
|
|||||||
let viewport_pos = selected_gradient
|
let viewport_pos = selected_gradient
|
||||||
.transform
|
.transform
|
||||||
.transform_point2(selected_gradient.gradient.start.lerp(selected_gradient.gradient.end, stop_pos));
|
.transform_point2(selected_gradient.gradient.start.lerp(selected_gradient.gradient.end, stop_pos));
|
||||||
|
let position = viewport_pos.into();
|
||||||
let color = selected_gradient.gradient.stops.color[stop_index].to_gamma_srgb();
|
let color = selected_gradient.gradient.stops.color[stop_index].to_gamma_srgb();
|
||||||
tool_data.color_picker_editing_color_stop = Some(stop_index);
|
tool_data.color_picker_editing_color_stop = Some(stop_index);
|
||||||
responses.add(FrontendMessage::UpdateGradientStopColorPickerPosition {
|
responses.add(FrontendMessage::UpdateGradientStopColorPickerPosition { color, position });
|
||||||
color,
|
|
||||||
x: viewport_pos.x,
|
|
||||||
y: viewport_pos.y,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -1188,8 +1187,8 @@ impl Fsm for GradientToolFsmState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert drag_start from document space to effective viewport space
|
// Convert drag_start from document space to effective viewport space
|
||||||
let d2v = document.metadata().document_to_viewport;
|
let document_to_viewport = document.metadata().document_to_viewport;
|
||||||
let drag_start_viewport = d2v.transform_point2(tool_data.drag_start) + tool_data.auto_pan_shift;
|
let drag_start_viewport = document_to_viewport.transform_point2(tool_data.drag_start) + tool_data.auto_pan_shift;
|
||||||
tool_data.auto_pan_shift = DVec2::ZERO;
|
tool_data.auto_pan_shift = DVec2::ZERO;
|
||||||
|
|
||||||
selected_gradient.update_gradient(
|
selected_gradient.update_gradient(
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ pub struct NavigateTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Navigate)]
|
#[impl_message(Message, ToolMessage, Navigate)]
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum NavigateToolMessage {
|
pub enum NavigateToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Abort,
|
Abort,
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ pub struct PathToolOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Path)]
|
#[impl_message(Message, ToolMessage, Path)]
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum PathToolMessage {
|
pub enum PathToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Abort,
|
Abort,
|
||||||
@@ -155,7 +156,8 @@ pub enum PathToolMessage {
|
|||||||
ToggleSegmentEditing,
|
ToggleSegmentEditing,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Hash, Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum PathOverlayMode {
|
pub enum PathOverlayMode {
|
||||||
AllHandles = 0,
|
AllHandles = 0,
|
||||||
#[default]
|
#[default]
|
||||||
@@ -178,7 +180,8 @@ impl Default for PathEditingMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum PathOptionsUpdate {
|
pub enum PathOptionsUpdate {
|
||||||
OverlayModeType(PathOverlayMode),
|
OverlayModeType(PathOverlayMode),
|
||||||
PointEditingMode { enabled: bool },
|
PointEditingMode { enabled: bool },
|
||||||
@@ -326,7 +329,7 @@ impl LayoutHolder for PathTool {
|
|||||||
|
|
||||||
// Works only if a single layer is selected and its type is Vector
|
// Works only if a single layer is selected and its type is Vector
|
||||||
let path_node_button = TextButton::new("Make Path Editable")
|
let path_node_button = TextButton::new("Make Path Editable")
|
||||||
.icon(Some("NodeShape".into()))
|
.icon("NodeShape")
|
||||||
.tooltip_label("Make Path Editable")
|
.tooltip_label("Make Path Editable")
|
||||||
.tooltip_description(
|
.tooltip_description(
|
||||||
"Enables the Pen and Path tools to directly edit layer geometry resulting from nondestructive operations. This inserts a 'Path' node as the last operation of the selected layer.",
|
"Enables the Pen and Path tools to directly edit layer geometry resulting from nondestructive operations. This inserts a 'Path' node as the last operation of the selected layer.",
|
||||||
@@ -349,32 +352,30 @@ impl LayoutHolder for PathTool {
|
|||||||
|
|
||||||
let _pin_pivot = pin_pivot_widget(self.tool_data.pivot_gizmo.pin_active(), false, PivotToolSource::Path);
|
let _pin_pivot = pin_pivot_widget(self.tool_data.pivot_gizmo.pin_active(), false, PivotToolSource::Path);
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row {
|
Layout(vec![LayoutGroup::row(vec![
|
||||||
widgets: vec![
|
x_location,
|
||||||
x_location,
|
related_seperator.clone(),
|
||||||
related_seperator.clone(),
|
y_location,
|
||||||
y_location,
|
unrelated_seperator.clone(),
|
||||||
unrelated_seperator.clone(),
|
colinear_handle_checkbox,
|
||||||
colinear_handle_checkbox,
|
related_seperator.clone(),
|
||||||
related_seperator.clone(),
|
colinear_handles_label,
|
||||||
colinear_handles_label,
|
unrelated_seperator.clone(),
|
||||||
unrelated_seperator.clone(),
|
point_editing_mode,
|
||||||
point_editing_mode,
|
related_seperator.clone(),
|
||||||
related_seperator.clone(),
|
segment_editing_mode,
|
||||||
segment_editing_mode,
|
unrelated_seperator.clone(),
|
||||||
unrelated_seperator.clone(),
|
path_overlay_mode_widget,
|
||||||
path_overlay_mode_widget,
|
unrelated_seperator.clone(),
|
||||||
unrelated_seperator.clone(),
|
path_node_button,
|
||||||
path_node_button,
|
// checkbox.clone(),
|
||||||
// checkbox.clone(),
|
// related_seperator.clone(),
|
||||||
// related_seperator.clone(),
|
// dropdown.clone(),
|
||||||
// dropdown.clone(),
|
// unrelated_seperator,
|
||||||
// unrelated_seperator,
|
// pivot_reference,
|
||||||
// pivot_reference,
|
// related_seperator.clone(),
|
||||||
// related_seperator.clone(),
|
// pin_pivot,
|
||||||
// pin_pivot,
|
])])
|
||||||
],
|
|
||||||
}])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use super::tool_prelude::*;
|
use super::tool_prelude::*;
|
||||||
use crate::consts::{COLOR_OVERLAY_BLUE, COLOR_OVERLAY_BLUE_05, DEFAULT_STROKE_WIDTH, HIDE_HANDLE_DISTANCE, LINE_ROTATE_SNAP_ANGLE, SEGMENT_OVERLAY_SIZE};
|
use crate::consts::{COLOR_OVERLAY_BLUE, COLOR_OVERLAY_BLUE_05, DEFAULT_STROKE_WIDTH, HIDE_HANDLE_DISTANCE, LINE_ROTATE_SNAP_ANGLE, SEGMENT_OVERLAY_SIZE};
|
||||||
use crate::messages::input_mapper::utility_types::input_mouse::MouseKeys;
|
use crate::messages::input_mapper::utility_types::input_mouse::MouseKeys;
|
||||||
|
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
|
||||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_network_node_type;
|
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_network_node_type;
|
||||||
use crate::messages::portfolio::document::overlays::utility_functions::path_overlays;
|
use crate::messages::portfolio::document::overlays::utility_functions::path_overlays;
|
||||||
use crate::messages::portfolio::document::overlays::utility_types::{DrawHandles, OverlayContext};
|
use crate::messages::portfolio::document::overlays::utility_types::{DrawHandles, OverlayContext};
|
||||||
@@ -44,7 +45,8 @@ impl Default for PenOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Pen)]
|
#[impl_message(Message, ToolMessage, Pen)]
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum PenToolMessage {
|
pub enum PenToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Abort,
|
Abort,
|
||||||
@@ -107,13 +109,15 @@ enum PenToolFsmState {
|
|||||||
GRSHandle,
|
GRSHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Copy, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Hash, Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum PenOverlayMode {
|
pub enum PenOverlayMode {
|
||||||
AllHandles = 0,
|
AllHandles = 0,
|
||||||
FrontierHandles = 1,
|
FrontierHandles = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum PenOptionsUpdate {
|
pub enum PenOptionsUpdate {
|
||||||
FillColor(Option<Color>),
|
FillColor(Option<Color>),
|
||||||
FillColorType(ToolColorType),
|
FillColorType(ToolColorType),
|
||||||
@@ -238,7 +242,7 @@ impl LayoutHolder for PenTool {
|
|||||||
.widget_instance(),
|
.widget_instance(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1294,9 +1298,34 @@ impl PenToolData {
|
|||||||
self.prior_segments = None;
|
self.prior_segments = None;
|
||||||
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![layer.to_node()] });
|
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![layer.to_node()] });
|
||||||
|
|
||||||
// It is necessary to defer this until the transform of the layer can be accurately computed (quite hacky)
|
// Set up the first point at local origin (0,0) and position the layer at the viewport location via Transform
|
||||||
|
let id = PointId::generate();
|
||||||
|
self.add_point(LastPoint {
|
||||||
|
id,
|
||||||
|
pos: DVec2::ZERO,
|
||||||
|
in_segment: None,
|
||||||
|
handle_start: DVec2::ZERO,
|
||||||
|
});
|
||||||
|
self.next_point = DVec2::ZERO;
|
||||||
|
self.next_handle_start = DVec2::ZERO;
|
||||||
|
self.handle_end = None;
|
||||||
|
|
||||||
|
// Defer the transform setup and point insertion until after the layer is created
|
||||||
responses.add(DeferMessage::AfterGraphRun {
|
responses.add(DeferMessage::AfterGraphRun {
|
||||||
messages: vec![PenToolMessage::AddPointLayerPosition { layer, viewport: viewport_vec }.into()],
|
messages: vec![
|
||||||
|
GraphOperationMessage::TransformSet {
|
||||||
|
layer,
|
||||||
|
transform: DAffine2::from_translation(viewport_vec),
|
||||||
|
transform_in: TransformIn::Viewport,
|
||||||
|
skip_rerender: false,
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
GraphOperationMessage::Vector {
|
||||||
|
layer,
|
||||||
|
modification_type: VectorModificationType::InsertPoint { id, position: DVec2::ZERO },
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ use crate::messages::tool::common_functionality::transformation_cage::*;
|
|||||||
use crate::messages::tool::common_functionality::utility_functions::{resize_bounds, rotate_bounds, skew_bounds, text_bounding_box, transforming_transform_cage};
|
use crate::messages::tool::common_functionality::utility_functions::{resize_bounds, rotate_bounds, skew_bounds, text_bounding_box, transforming_transform_cage};
|
||||||
use glam::DMat2;
|
use glam::DMat2;
|
||||||
use graph_craft::document::NodeId;
|
use graph_craft::document::NodeId;
|
||||||
use graphene_std::path_bool::BooleanOperation;
|
|
||||||
use graphene_std::renderer::Quad;
|
use graphene_std::renderer::Quad;
|
||||||
use graphene_std::renderer::Rect;
|
use graphene_std::renderer::Rect;
|
||||||
use graphene_std::subpath::Subpath;
|
use graphene_std::subpath::Subpath;
|
||||||
use graphene_std::transform::ReferencePoint;
|
use graphene_std::transform::ReferencePoint;
|
||||||
|
use graphene_std::vector::misc::BooleanOperation;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Default, ExtractField)]
|
#[derive(Default, ExtractField)]
|
||||||
@@ -42,7 +42,8 @@ pub struct SelectOptions {
|
|||||||
nested_selection_behavior: NestedSelectionBehavior,
|
nested_selection_behavior: NestedSelectionBehavior,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum SelectOptionsUpdate {
|
pub enum SelectOptionsUpdate {
|
||||||
NestedSelectionBehavior(NestedSelectionBehavior),
|
NestedSelectionBehavior(NestedSelectionBehavior),
|
||||||
PivotGizmoType(PivotGizmoType),
|
PivotGizmoType(PivotGizmoType),
|
||||||
@@ -50,7 +51,8 @@ pub enum SelectOptionsUpdate {
|
|||||||
TogglePivotPinned,
|
TogglePivotPinned,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Hash, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum NestedSelectionBehavior {
|
pub enum NestedSelectionBehavior {
|
||||||
#[default]
|
#[default]
|
||||||
Shallowest,
|
Shallowest,
|
||||||
@@ -66,7 +68,8 @@ impl fmt::Display for NestedSelectionBehavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct SelectToolPointerKeys {
|
pub struct SelectToolPointerKeys {
|
||||||
pub axis_align: Key,
|
pub axis_align: Key,
|
||||||
pub snap_angle: Key,
|
pub snap_angle: Key,
|
||||||
@@ -75,7 +78,8 @@ pub struct SelectToolPointerKeys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Select)]
|
#[impl_message(Message, ToolMessage, Select)]
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum SelectToolMessage {
|
pub enum SelectToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Abort,
|
Abort,
|
||||||
@@ -265,7 +269,7 @@ impl LayoutHolder for SelectTool {
|
|||||||
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
|
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
|
||||||
widgets.extend(self.boolean_widgets(self.tool_data.selected_layers_count));
|
widgets.extend(self.boolean_widgets(self.tool_data.selected_layers_count));
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use super::tool_prelude::*;
|
use super::tool_prelude::*;
|
||||||
use crate::consts::{DEFAULT_STROKE_WIDTH, SNAP_POINT_TOLERANCE};
|
use crate::consts::{BOUNDS_SELECT_THRESHOLD, DEFAULT_STROKE_WIDTH, SNAP_POINT_TOLERANCE};
|
||||||
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
|
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
|
||||||
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
||||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||||
@@ -12,9 +12,9 @@ use crate::messages::tool::common_functionality::shapes::arc_shape::Arc;
|
|||||||
use crate::messages::tool::common_functionality::shapes::arrow_shape::Arrow;
|
use crate::messages::tool::common_functionality::shapes::arrow_shape::Arrow;
|
||||||
use crate::messages::tool::common_functionality::shapes::circle_shape::Circle;
|
use crate::messages::tool::common_functionality::shapes::circle_shape::Circle;
|
||||||
use crate::messages::tool::common_functionality::shapes::grid_shape::Grid;
|
use crate::messages::tool::common_functionality::shapes::grid_shape::Grid;
|
||||||
use crate::messages::tool::common_functionality::shapes::line_shape::{LineToolData, clicked_on_line_endpoints};
|
use crate::messages::tool::common_functionality::shapes::line_shape::LineToolData;
|
||||||
use crate::messages::tool::common_functionality::shapes::polygon_shape::Polygon;
|
use crate::messages::tool::common_functionality::shapes::polygon_shape::Polygon;
|
||||||
use crate::messages::tool::common_functionality::shapes::shape_utility::{ShapeToolModifierKey, ShapeType, anchor_overlays, transform_cage_overlays};
|
use crate::messages::tool::common_functionality::shapes::shape_utility::{ShapeToolModifierKey, ShapeType, anchor_overlays, clicked_on_shape_endpoints, transform_cage_overlays};
|
||||||
use crate::messages::tool::common_functionality::shapes::spiral_shape::Spiral;
|
use crate::messages::tool::common_functionality::shapes::spiral_shape::Spiral;
|
||||||
use crate::messages::tool::common_functionality::shapes::star_shape::Star;
|
use crate::messages::tool::common_functionality::shapes::star_shape::Star;
|
||||||
use crate::messages::tool::common_functionality::shapes::{Ellipse, Line, Rectangle};
|
use crate::messages::tool::common_functionality::shapes::{Ellipse, Line, Rectangle};
|
||||||
@@ -68,7 +68,8 @@ impl Default for ShapeToolOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ShapeOptionsUpdate {
|
pub enum ShapeOptionsUpdate {
|
||||||
FillColor(Option<Color>),
|
FillColor(Option<Color>),
|
||||||
FillColorType(ToolColorType),
|
FillColorType(ToolColorType),
|
||||||
@@ -88,7 +89,8 @@ pub enum ShapeOptionsUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[impl_message(Message, ToolMessage, Shape)]
|
#[impl_message(Message, ToolMessage, Shape)]
|
||||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
|
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ShapeToolMessage {
|
pub enum ShapeToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
Overlays { context: OverlayContext },
|
Overlays { context: OverlayContext },
|
||||||
@@ -103,6 +105,7 @@ pub enum ShapeToolMessage {
|
|||||||
PointerOutsideViewport { modifier: ShapeToolModifierKey },
|
PointerOutsideViewport { modifier: ShapeToolModifierKey },
|
||||||
UpdateOptions { options: ShapeOptionsUpdate },
|
UpdateOptions { options: ShapeOptionsUpdate },
|
||||||
SetShape { shape: ShapeType },
|
SetShape { shape: ShapeType },
|
||||||
|
SyncShapeWithOptions,
|
||||||
|
|
||||||
IncreaseSides,
|
IncreaseSides,
|
||||||
DecreaseSides,
|
DecreaseSides,
|
||||||
@@ -178,30 +181,12 @@ fn create_shape_option_widget(shape_type: ShapeType) -> WidgetInstance {
|
|||||||
}
|
}
|
||||||
.into()
|
.into()
|
||||||
}),
|
}),
|
||||||
MenuListEntry::new("Rectangle").label("Rectangle").on_commit(move |_| {
|
|
||||||
ShapeToolMessage::UpdateOptions {
|
|
||||||
options: ShapeOptionsUpdate::ShapeType(ShapeType::Rectangle),
|
|
||||||
}
|
|
||||||
.into()
|
|
||||||
}),
|
|
||||||
MenuListEntry::new("Ellipse").label("Ellipse").on_commit(move |_| {
|
|
||||||
ShapeToolMessage::UpdateOptions {
|
|
||||||
options: ShapeOptionsUpdate::ShapeType(ShapeType::Ellipse),
|
|
||||||
}
|
|
||||||
.into()
|
|
||||||
}),
|
|
||||||
MenuListEntry::new("Arrow").label("Arrow").on_commit(move |_| {
|
MenuListEntry::new("Arrow").label("Arrow").on_commit(move |_| {
|
||||||
ShapeToolMessage::UpdateOptions {
|
ShapeToolMessage::UpdateOptions {
|
||||||
options: ShapeOptionsUpdate::ShapeType(ShapeType::Arrow),
|
options: ShapeOptionsUpdate::ShapeType(ShapeType::Arrow),
|
||||||
}
|
}
|
||||||
.into()
|
.into()
|
||||||
}),
|
}),
|
||||||
MenuListEntry::new("Line").label("Line").on_commit(move |_| {
|
|
||||||
ShapeToolMessage::UpdateOptions {
|
|
||||||
options: ShapeOptionsUpdate::ShapeType(ShapeType::Line),
|
|
||||||
}
|
|
||||||
.into()
|
|
||||||
}),
|
|
||||||
]];
|
]];
|
||||||
DropdownInput::new(entries).selected_index(Some(shape_type as u32)).widget_instance()
|
DropdownInput::new(entries).selected_index(Some(shape_type as u32)).widget_instance()
|
||||||
}
|
}
|
||||||
@@ -423,7 +408,7 @@ impl LayoutHolder for ShapeTool {
|
|||||||
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
|
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
|
||||||
widgets.push(create_weight_widget(self.options.line_weight));
|
widgets.push(create_weight_widget(self.options.line_weight));
|
||||||
|
|
||||||
Layout(vec![LayoutGroup::Row { widgets }])
|
Layout(vec![LayoutGroup::row(widgets)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,11 +645,11 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
tool_options: &Self::ToolOptions,
|
tool_options: &Self::ToolOptions,
|
||||||
responses: &mut VecDeque<Message>,
|
responses: &mut VecDeque<Message>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let all_selected_layers_line = document
|
let all_selected_layers_line_or_arrow = document
|
||||||
.network_interface
|
.network_interface
|
||||||
.selected_nodes()
|
.selected_nodes()
|
||||||
.selected_visible_and_unlocked_layers(&document.network_interface)
|
.selected_visible_and_unlocked_layers(&document.network_interface)
|
||||||
.all(|layer| graph_modification_utils::get_line_id(layer, &document.network_interface).is_some());
|
.all(|layer| graph_modification_utils::get_line_id(layer, &document.network_interface).is_some() || graph_modification_utils::get_arrow_id(layer, &document.network_interface).is_some());
|
||||||
|
|
||||||
let ToolMessage::Shape(event) = event else { return self };
|
let ToolMessage::Shape(event) = event else { return self };
|
||||||
|
|
||||||
@@ -692,7 +677,15 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
let modifying_transform_cage = matches!(self, ShapeToolFsmState::ResizingBounds | ShapeToolFsmState::RotatingBounds | ShapeToolFsmState::SkewingBounds { .. });
|
let modifying_transform_cage = matches!(self, ShapeToolFsmState::ResizingBounds | ShapeToolFsmState::RotatingBounds | ShapeToolFsmState::SkewingBounds { .. });
|
||||||
let hovering_over_gizmo = tool_data.gizmo_manager.hovering_over_gizmo();
|
let hovering_over_gizmo = tool_data.gizmo_manager.hovering_over_gizmo();
|
||||||
|
|
||||||
if !matches!(self, ShapeToolFsmState::ModifyingGizmo) && !modifying_transform_cage && !hovering_over_gizmo {
|
// Check if hovering over a line/arrow endpoint (using data from previous overlay pass)
|
||||||
|
let hovering_over_endpoint = tool_data.line_data.selected_layers_with_position.iter().any(|(layer, endpoints)| {
|
||||||
|
let transform = document.metadata().transform_to_viewport(*layer);
|
||||||
|
endpoints
|
||||||
|
.iter()
|
||||||
|
.any(|&local_pos| (transform.transform_point2(local_pos) - input.mouse.position).length_squared() < BOUNDS_SELECT_THRESHOLD.powi(2))
|
||||||
|
});
|
||||||
|
|
||||||
|
if !matches!(self, ShapeToolFsmState::ModifyingGizmo) && !modifying_transform_cage && !hovering_over_gizmo && !hovering_over_endpoint {
|
||||||
tool_data.data.snap_manager.draw_overlays(SnapData::new(document, input, viewport), &mut overlay_context);
|
tool_data.data.snap_manager.draw_overlays(SnapData::new(document, input, viewport), &mut overlay_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -705,9 +698,13 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
anchor_overlays(document, &mut overlay_context);
|
anchor_overlays(document, &mut overlay_context);
|
||||||
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Crosshair });
|
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Crosshair });
|
||||||
} else if matches!(self, ShapeToolFsmState::Ready(_)) {
|
} else if matches!(self, ShapeToolFsmState::Ready(_)) {
|
||||||
Line::overlays(document, tool_data, &mut overlay_context);
|
Line::overlays(document, tool_data, input.mouse.position, &mut overlay_context);
|
||||||
|
Arrow::overlays(document, tool_data, input.mouse.position, &mut overlay_context);
|
||||||
|
|
||||||
if all_selected_layers_line {
|
if all_selected_layers_line_or_arrow {
|
||||||
|
let cursor = if hovering_over_endpoint { MouseCursorIcon::Default } else { MouseCursorIcon::Crosshair };
|
||||||
|
tool_data.cursor = cursor;
|
||||||
|
responses.add(FrontendMessage::UpdateMouseCursor { cursor });
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -736,14 +733,20 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let cursor = tool_data.gizmo_manager.mouse_cursor_icon().unwrap_or_else(|| tool_data.transform_cage_mouse_icon(input));
|
let cursor = tool_data
|
||||||
|
.gizmo_manager
|
||||||
|
.mouse_cursor_icon()
|
||||||
|
.or_else(|| hovering_over_endpoint.then_some(MouseCursorIcon::Default))
|
||||||
|
.unwrap_or_else(|| tool_data.transform_cage_mouse_icon(input));
|
||||||
|
|
||||||
tool_data.cursor = cursor;
|
tool_data.cursor = cursor;
|
||||||
responses.add(FrontendMessage::UpdateMouseCursor { cursor });
|
responses.add(FrontendMessage::UpdateMouseCursor { cursor });
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches!(self, ShapeToolFsmState::Drawing(_) | ShapeToolFsmState::DraggingLineEndpoints) {
|
if matches!(self, ShapeToolFsmState::Drawing(_) | ShapeToolFsmState::DraggingLineEndpoints) {
|
||||||
Line::overlays(document, tool_data, &mut overlay_context);
|
Line::overlays(document, tool_data, input.mouse.position, &mut overlay_context);
|
||||||
|
Arrow::overlays(document, tool_data, input.mouse.position, &mut overlay_context);
|
||||||
|
|
||||||
if tool_options.shape_type == ShapeType::Circle {
|
if tool_options.shape_type == ShapeType::Circle {
|
||||||
tool_data.gizmo_manager.overlays(document, input, shape_editor, mouse_position, &mut overlay_context);
|
tool_data.gizmo_manager.overlays(document, input, shape_editor, mouse_position, &mut overlay_context);
|
||||||
}
|
}
|
||||||
@@ -851,14 +854,14 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
return ShapeToolFsmState::ModifyingGizmo;
|
return ShapeToolFsmState::ModifyingGizmo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If clicked on endpoints of a selected line, drag its endpoints
|
// If clicked on endpoints of a selected line or arrow, drag its endpoints
|
||||||
if let Some((layer, _, _)) = closest_point(
|
if let Some((layer, _, _)) = closest_point(
|
||||||
document,
|
document,
|
||||||
mouse_pos,
|
mouse_pos,
|
||||||
SNAP_POINT_TOLERANCE,
|
SNAP_POINT_TOLERANCE,
|
||||||
document.network_interface.selected_nodes().selected_visible_and_unlocked_layers(&document.network_interface),
|
document.network_interface.selected_nodes().selected_visible_and_unlocked_layers(&document.network_interface),
|
||||||
|_| false,
|
|_| false,
|
||||||
) && clicked_on_line_endpoints(layer, document, input, tool_data)
|
) && clicked_on_shape_endpoints(layer, document, input, tool_data)
|
||||||
&& !input.keyboard.key(Key::Control)
|
&& !input.keyboard.key(Key::Control)
|
||||||
{
|
{
|
||||||
responses.add(DocumentMessage::StartTransaction);
|
responses.add(DocumentMessage::StartTransaction);
|
||||||
@@ -924,16 +927,10 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
ShapeType::Arc => Arc::create_node(tool_options.arc_type),
|
ShapeType::Arc => Arc::create_node(tool_options.arc_type),
|
||||||
ShapeType::Spiral => Spiral::create_node(tool_options.spiral_type, tool_options.turns),
|
ShapeType::Spiral => Spiral::create_node(tool_options.spiral_type, tool_options.turns),
|
||||||
ShapeType::Grid => Grid::create_node(tool_options.grid_type),
|
ShapeType::Grid => Grid::create_node(tool_options.grid_type),
|
||||||
|
ShapeType::Arrow => Arrow::create_node(tool_options.arrow_shaft_width, tool_options.arrow_head_width, tool_options.arrow_head_length),
|
||||||
|
ShapeType::Line => Line::create_node(),
|
||||||
ShapeType::Rectangle => Rectangle::create_node(),
|
ShapeType::Rectangle => Rectangle::create_node(),
|
||||||
ShapeType::Ellipse => Ellipse::create_node(),
|
ShapeType::Ellipse => Ellipse::create_node(),
|
||||||
ShapeType::Arrow => Arrow::create_node(
|
|
||||||
document,
|
|
||||||
tool_data.data.drag_start,
|
|
||||||
tool_options.arrow_shaft_width,
|
|
||||||
tool_options.arrow_head_width,
|
|
||||||
tool_options.arrow_head_length,
|
|
||||||
),
|
|
||||||
ShapeType::Line => Line::create_node(document, tool_data.data.drag_start),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let nodes = vec![(NodeId(0), node)];
|
let nodes = vec![(NodeId(0), node)];
|
||||||
@@ -941,8 +938,6 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
|
|
||||||
let defered_responses = &mut VecDeque::new();
|
let defered_responses = &mut VecDeque::new();
|
||||||
|
|
||||||
tool_options.stroke.apply_stroke(tool_options.line_weight, layer, defered_responses);
|
|
||||||
|
|
||||||
match tool_data.current_shape {
|
match tool_data.current_shape {
|
||||||
ShapeType::Polygon | ShapeType::Star | ShapeType::Circle | ShapeType::Arc | ShapeType::Spiral | ShapeType::Grid | ShapeType::Rectangle | ShapeType::Ellipse => {
|
ShapeType::Polygon | ShapeType::Star | ShapeType::Circle | ShapeType::Arc | ShapeType::Spiral | ShapeType::Grid | ShapeType::Rectangle | ShapeType::Ellipse => {
|
||||||
defered_responses.add(GraphOperationMessage::TransformSet {
|
defered_responses.add(GraphOperationMessage::TransformSet {
|
||||||
@@ -952,16 +947,35 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
skip_rerender: false,
|
skip_rerender: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tool_options.stroke.apply_stroke(tool_options.line_weight, layer, defered_responses);
|
||||||
tool_options.fill.apply_fill(layer, defered_responses);
|
tool_options.fill.apply_fill(layer, defered_responses);
|
||||||
}
|
}
|
||||||
ShapeType::Arrow => {
|
ShapeType::Arrow => {
|
||||||
|
let viewport_drag_start = tool_data.data.viewport_drag_start(document);
|
||||||
|
defered_responses.add(GraphOperationMessage::TransformSet {
|
||||||
|
layer,
|
||||||
|
transform: DAffine2::from_scale_angle_translation(DVec2::ONE, 0., viewport_drag_start),
|
||||||
|
transform_in: TransformIn::Viewport,
|
||||||
|
skip_rerender: false,
|
||||||
|
});
|
||||||
|
|
||||||
tool_data.line_data.weight = tool_options.line_weight;
|
tool_data.line_data.weight = tool_options.line_weight;
|
||||||
tool_data.line_data.editing_layer = Some(layer);
|
tool_data.line_data.editing_layer = Some(layer);
|
||||||
|
tool_options.stroke.apply_stroke(tool_options.line_weight, layer, defered_responses);
|
||||||
tool_options.fill.apply_fill(layer, defered_responses);
|
tool_options.fill.apply_fill(layer, defered_responses);
|
||||||
}
|
}
|
||||||
ShapeType::Line => {
|
ShapeType::Line => {
|
||||||
|
let viewport_drag_start = tool_data.data.viewport_drag_start(document);
|
||||||
|
defered_responses.add(GraphOperationMessage::TransformSet {
|
||||||
|
layer,
|
||||||
|
transform: DAffine2::from_scale_angle_translation(DVec2::ONE, 0., viewport_drag_start),
|
||||||
|
transform_in: TransformIn::Viewport,
|
||||||
|
skip_rerender: false,
|
||||||
|
});
|
||||||
|
|
||||||
tool_data.line_data.weight = tool_options.line_weight;
|
tool_data.line_data.weight = tool_options.line_weight;
|
||||||
tool_data.line_data.editing_layer = Some(layer);
|
tool_data.line_data.editing_layer = Some(layer);
|
||||||
|
tool_options.stroke.apply_stroke(tool_options.line_weight, layer, defered_responses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -984,12 +998,12 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
ShapeType::Star => Star::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
ShapeType::Star => Star::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
||||||
ShapeType::Circle => Circle::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
ShapeType::Circle => Circle::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
||||||
ShapeType::Arc => Arc::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
ShapeType::Arc => Arc::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
||||||
ShapeType::Arrow => Arrow::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
|
||||||
ShapeType::Spiral => Spiral::update_shape(document, input, viewport, layer, tool_data, responses),
|
ShapeType::Spiral => Spiral::update_shape(document, input, viewport, layer, tool_data, responses),
|
||||||
ShapeType::Grid => Grid::update_shape(document, input, layer, tool_options.grid_type, tool_data, modifier, responses),
|
ShapeType::Grid => Grid::update_shape(document, input, layer, tool_options.grid_type, tool_data, modifier, responses),
|
||||||
|
ShapeType::Arrow => Arrow::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
||||||
|
ShapeType::Line => Line::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
||||||
ShapeType::Rectangle => Rectangle::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
ShapeType::Rectangle => Rectangle::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
||||||
ShapeType::Ellipse => Ellipse::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
ShapeType::Ellipse => Ellipse::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
||||||
ShapeType::Line => Line::update_shape(document, input, viewport, layer, tool_data, modifier, responses),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-panning
|
// Auto-panning
|
||||||
@@ -1003,7 +1017,12 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
return ShapeToolFsmState::Ready(tool_data.current_shape);
|
return ShapeToolFsmState::Ready(tool_data.current_shape);
|
||||||
};
|
};
|
||||||
|
|
||||||
Line::update_shape(document, input, viewport, layer, tool_data, modifier, responses);
|
if graph_modification_utils::get_arrow_id(layer, &document.network_interface).is_some() {
|
||||||
|
Arrow::update_shape(document, input, viewport, layer, tool_data, modifier, responses);
|
||||||
|
} else {
|
||||||
|
Line::update_shape(document, input, viewport, layer, tool_data, modifier, responses);
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-panning
|
// Auto-panning
|
||||||
let messages = [ShapeToolMessage::PointerOutsideViewport { modifier }.into(), ShapeToolMessage::PointerMove { modifier }.into()];
|
let messages = [ShapeToolMessage::PointerOutsideViewport { modifier }.into(), ShapeToolMessage::PointerMove { modifier }.into()];
|
||||||
tool_data.auto_panning.setup_by_mouse_position(input, viewport, &messages, responses);
|
tool_data.auto_panning.setup_by_mouse_position(input, viewport, &messages, responses);
|
||||||
@@ -1170,15 +1189,16 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
responses.add(DocumentMessage::AbortTransaction);
|
responses.add(DocumentMessage::AbortTransaction);
|
||||||
tool_data.data.cleanup(responses);
|
tool_data.data.cleanup(responses);
|
||||||
tool_data.current_shape = shape;
|
tool_data.current_shape = shape;
|
||||||
responses.add(ShapeToolMessage::UpdateOptions {
|
// Update hints for the new shape (without updating options.shape_type)
|
||||||
options: ShapeOptionsUpdate::ShapeType(shape),
|
update_dynamic_hints(&ShapeToolFsmState::Ready(shape), responses, tool_data);
|
||||||
});
|
|
||||||
|
|
||||||
responses.add(ShapeToolMessage::UpdateOptions {
|
|
||||||
options: ShapeOptionsUpdate::ShapeType(shape),
|
|
||||||
});
|
|
||||||
ShapeToolFsmState::Ready(shape)
|
ShapeToolFsmState::Ready(shape)
|
||||||
}
|
}
|
||||||
|
(_, ShapeToolMessage::SyncShapeWithOptions) => {
|
||||||
|
// Sync current_shape with the dropdown selection when returning from alias tools
|
||||||
|
tool_data.current_shape = tool_options.shape_type;
|
||||||
|
update_dynamic_hints(&ShapeToolFsmState::Ready(tool_options.shape_type), responses, tool_data);
|
||||||
|
ShapeToolFsmState::Ready(tool_options.shape_type)
|
||||||
|
}
|
||||||
(_, ShapeToolMessage::HideShapeTypeWidget { hide }) => {
|
(_, ShapeToolMessage::HideShapeTypeWidget { hide }) => {
|
||||||
tool_data.hide_shape_option_widget = hide;
|
tool_data.hide_shape_option_widget = hide;
|
||||||
responses.add(ToolMessage::RefreshToolOptions);
|
responses.add(ToolMessage::RefreshToolOptions);
|
||||||
@@ -1209,15 +1229,30 @@ fn update_dynamic_hints(state: &ShapeToolFsmState, responses: &mut VecDeque<Mess
|
|||||||
]),
|
]),
|
||||||
HintGroup(vec![HintInfo::multi_keys([[Key::BracketLeft], [Key::BracketRight]], "Decrease/Increase Sides")]),
|
HintGroup(vec![HintInfo::multi_keys([[Key::BracketLeft], [Key::BracketRight]], "Decrease/Increase Sides")]),
|
||||||
],
|
],
|
||||||
|
ShapeType::Circle => vec![HintGroup(vec![
|
||||||
|
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Circle"),
|
||||||
|
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
||||||
|
])],
|
||||||
|
ShapeType::Arc => vec![HintGroup(vec![
|
||||||
|
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Arc"),
|
||||||
|
HintInfo::keys([Key::Shift], "Constrain Arc").prepend_plus(),
|
||||||
|
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
||||||
|
])],
|
||||||
ShapeType::Spiral => vec![
|
ShapeType::Spiral => vec![
|
||||||
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Draw Spiral")]),
|
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Draw Spiral")]),
|
||||||
HintGroup(vec![HintInfo::multi_keys([[Key::BracketLeft], [Key::BracketRight]], "Decrease/Increase Turns")]),
|
HintGroup(vec![HintInfo::multi_keys([[Key::BracketLeft], [Key::BracketRight]], "Decrease/Increase Turns")]),
|
||||||
],
|
],
|
||||||
ShapeType::Ellipse => vec![HintGroup(vec![
|
ShapeType::Grid => vec![HintGroup(vec![
|
||||||
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Ellipse"),
|
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Grid"),
|
||||||
HintInfo::keys([Key::Shift], "Constrain Circular").prepend_plus(),
|
HintInfo::keys([Key::Shift], "Constrain Regular").prepend_plus(),
|
||||||
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
||||||
])],
|
])],
|
||||||
|
ShapeType::Arrow => vec![HintGroup(vec![
|
||||||
|
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Arrow"),
|
||||||
|
HintInfo::keys([Key::Shift], "15° Increments").prepend_plus(),
|
||||||
|
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
||||||
|
HintInfo::keys([Key::Control], "Lock Angle").prepend_plus(),
|
||||||
|
])],
|
||||||
ShapeType::Line => vec![HintGroup(vec![
|
ShapeType::Line => vec![HintGroup(vec![
|
||||||
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Line"),
|
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Line"),
|
||||||
HintInfo::keys([Key::Shift], "15° Increments").prepend_plus(),
|
HintInfo::keys([Key::Shift], "15° Increments").prepend_plus(),
|
||||||
@@ -1229,21 +1264,11 @@ fn update_dynamic_hints(state: &ShapeToolFsmState, responses: &mut VecDeque<Mess
|
|||||||
HintInfo::keys([Key::Shift], "Constrain Square").prepend_plus(),
|
HintInfo::keys([Key::Shift], "Constrain Square").prepend_plus(),
|
||||||
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
||||||
])],
|
])],
|
||||||
ShapeType::Circle => vec![HintGroup(vec![
|
ShapeType::Ellipse => vec![HintGroup(vec![
|
||||||
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Circle"),
|
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Ellipse"),
|
||||||
|
HintInfo::keys([Key::Shift], "Constrain Circular").prepend_plus(),
|
||||||
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
||||||
])],
|
])],
|
||||||
ShapeType::Arc => vec![HintGroup(vec![
|
|
||||||
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Arc"),
|
|
||||||
HintInfo::keys([Key::Shift], "Constrain Arc").prepend_plus(),
|
|
||||||
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
|
||||||
])],
|
|
||||||
ShapeType::Grid => vec![HintGroup(vec![
|
|
||||||
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Grid"),
|
|
||||||
HintInfo::keys([Key::Shift], "Constrain Regular").prepend_plus(),
|
|
||||||
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
|
||||||
])],
|
|
||||||
ShapeType::Arrow => vec![HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Draw Arrow")])],
|
|
||||||
};
|
};
|
||||||
HintData(hint_groups)
|
HintData(hint_groups)
|
||||||
}
|
}
|
||||||
@@ -1251,17 +1276,21 @@ fn update_dynamic_hints(state: &ShapeToolFsmState, responses: &mut VecDeque<Mess
|
|||||||
let mut common_hint_group = vec![HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, ""), HintInfo::keys([Key::Escape], "Cancel").prepend_slash()])];
|
let mut common_hint_group = vec![HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, ""), HintInfo::keys([Key::Escape], "Cancel").prepend_slash()])];
|
||||||
let tool_hint_group = match shape {
|
let tool_hint_group = match shape {
|
||||||
ShapeType::Polygon | ShapeType::Star | ShapeType::Arc => HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Regular"), HintInfo::keys([Key::Alt], "From Center")]),
|
ShapeType::Polygon | ShapeType::Star | ShapeType::Arc => HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Regular"), HintInfo::keys([Key::Alt], "From Center")]),
|
||||||
ShapeType::Rectangle => HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Square"), HintInfo::keys([Key::Alt], "From Center")]),
|
ShapeType::Circle => HintGroup(vec![HintInfo::keys([Key::Alt], "From Center")]),
|
||||||
ShapeType::Ellipse => HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Circular"), HintInfo::keys([Key::Alt], "From Center")]),
|
ShapeType::Spiral => HintGroup(vec![]),
|
||||||
ShapeType::Grid => HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Regular"), HintInfo::keys([Key::Alt], "From Center")]),
|
ShapeType::Grid => HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Regular"), HintInfo::keys([Key::Alt], "From Center")]),
|
||||||
|
ShapeType::Arrow => HintGroup(vec![
|
||||||
|
HintInfo::keys([Key::Shift], "15° Increments"),
|
||||||
|
HintInfo::keys([Key::Alt], "From Center"),
|
||||||
|
HintInfo::keys([Key::Control], "Lock Angle"),
|
||||||
|
]),
|
||||||
ShapeType::Line => HintGroup(vec![
|
ShapeType::Line => HintGroup(vec![
|
||||||
HintInfo::keys([Key::Shift], "15° Increments"),
|
HintInfo::keys([Key::Shift], "15° Increments"),
|
||||||
HintInfo::keys([Key::Alt], "From Center"),
|
HintInfo::keys([Key::Alt], "From Center"),
|
||||||
HintInfo::keys([Key::Control], "Lock Angle"),
|
HintInfo::keys([Key::Control], "Lock Angle"),
|
||||||
]),
|
]),
|
||||||
ShapeType::Arrow => HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Angle")]),
|
ShapeType::Rectangle => HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Square"), HintInfo::keys([Key::Alt], "From Center")]),
|
||||||
ShapeType::Circle => HintGroup(vec![HintInfo::keys([Key::Alt], "From Center")]),
|
ShapeType::Ellipse => HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Circular"), HintInfo::keys([Key::Alt], "From Center")]),
|
||||||
ShapeType::Spiral => HintGroup(vec![]),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if !tool_hint_group.0.is_empty() {
|
if !tool_hint_group.0.is_empty() {
|
||||||
|
|||||||
Loaded 100 of 427 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user